ycl

Artifact [e6ee309e66]
Login

Artifact [e6ee309e66]

Artifact e6ee309e667b7da2035a6f541bbf906c38fb5a47:


#! /bin/env tclsh

package require {ycl shelf shelf}

[yclprefix] shelf shelf .spawn [namespace current]

variable doc::init {
	description {
		initialize this thing.
	}
	args {
		_ {
			description {
				This shelf .
			}
		}
		algo {
			description {
				Which algorithm to employ .
			}
			constrain {
				$algo in [$_ $ algorithms]
			}
			default {
				lindex 256
			}
		}
		path {
			description {
				Path of a file to get the signature of .
			}
			default {}
		}
		read {
			description {
				Which mode to read in .  In text mode, newlines are
				normalized to the standard Tcl newline character prior
				to producing the digest.
			}
			default {
				lindex binary 
			}
			constrain {
				$read in {b binary t text}
			}
			process {
				switch $read {
					b - binary {
						set read binary
					}
					t - text {
						set read text
					}
				}
				set read
			}
		}
		report {
			description {
				what sort output to provide
			}
			constrain {
				$report in  {hex bin details coreutils soldigest
				soldigestverbose}
			}
			default {}
		}
	}
}


variable doc::digest {
	description {
		Produce an sha digest of some content.
	}
}
[namespace current] .method digest

proc init {_ args} {
	namespace eval ${_}::doc {}
	$_ $ doc::configure [$_ $ doc::init]
	$_ configure {*}$args
	set configure [$_ $ doc::configure]
	set cargs [dict get $configure args]
	foreach key [dict keys $cargs] {
		dict set cargs $key default {}
	}
	dict set configure args $cargs
	$_ $ doc::configure $configure
	return $_
}
[namespace current] .method init

variable algorithms {1 224 256 384 512}