Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions cecb/cecb-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Bash completion for the `cecb` ToolShed command (CECB File Tools Executive)
# Source this file (e.g. from ~/.bashrc) or drop it in
# /etc/bash_completion.d/ or /usr/local/etc/bash_completion.d/

_cecb()
{
local cur prev cmd
COMPREPLY=()

cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

# Global options
local global_opts="
-r
-t
-n
-s
-z
"

# Subcommands
local commands="
bulkerase
copy
dir
dumpblock
fstat
leader
"

#
# Find the subcommand (first non-option argument).
#
cmd=
for ((i=1; i<COMP_CWORD; i++)); do
case "${COMP_WORDS[i]}" in
-*)
;;
*)
cmd="${COMP_WORDS[i]}"
break
;;
esac
done

#
# No subcommand yet.
#
if [[ -z "$cmd" ]]; then
if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W "$global_opts" -- "$cur") )
else
COMPREPLY=( $(compgen -W "$commands" -- "$cur") )
fi
return
fi

case "$cmd" in
bulkerase)
case "$prev" in
-s)
COMPREPLY=( $(compgen -W "11025 22050 44100 48000 96000" -- "$cur") )
return
;;
-b)
COMPREPLY=( $(compgen -W "8 16 24 32" -- "$cur") )
return
;;
esac

if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W "
-s
-b
-l
" -- "$cur") )
else
COMPREPLY=( $(compgen -f -- "$cur") )
fi
;;

copy)
case "$prev" in
-d|-e)
return
;;
esac

if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W "
-0
-1
-2
-3
-a
-b
-g
-n
-d
-e
-l
-t
-k
-s
-f
-c
-p
" -- "$cur") )
else
COMPREPLY=( $(compgen -f -- "$cur") )
fi
;;

dir|fstat|leader|dumpblock)
if [[ "$cur" == -* ]]; then
[[ "$cmd" == dumpblock ]] &&
COMPREPLY=( $(compgen -W "-h" -- "$cur") )
else
COMPREPLY=( $(compgen -f -- "$cur") )
fi
;;
esac
}

complete -F _cecb cecb
127 changes: 127 additions & 0 deletions cecb/cecb_zsh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#compdef cecb
#
# Copy this file to a special directory as _cecb (plain filename with underscore)
# Check your $fpath for possible locations

# Show ambiguous completions immediately instead of beeping first
setopt AUTO_LIST
setopt NO_LIST_BEEP # optional: silence the bell entirely

_cecb() {
local context state state_descr line
typeset -A opt_args

local -a global_opts
global_opts=(
'-r+[Set WAV FSK aspect ratio]:ratio:'
'-t+[Set WAV FSK aspect ratio threshold]:threshold:'
'-n+[Set near-zero threshold]:threshold:'
'-s+[Start at sample/bit]:offset:'
'-z[Suggest MC-10 mode]'
)

local -a commands
commands=(
'bulkerase:Create cassette image files'
'copy:Copy files to an image'
'dir:Display image directory'
'dumpblock:Hex dump cassette blocks'
'dump:Display the contents of a file in hexadecimal'
'fstat:Display file information'
'leader:Analyze WAV leaders'
)

# Use *:: to shift $words so $words[1] becomes the subcommand in the nested state
_arguments -s -C \
$global_opts \
'1:command:->command' \
'*::subcommand args:->args'

case $state in
command)
_describe 'cecb command' commands
;;
args)
# Since *:: shifted $words, the subcommand is now exactly $words[1]
local cmd="$words[1]"

case "$cmd" in
bulkerase)
_arguments -s \
$global_opts \
'-s+[Sample rate]:sample rate:(11025 22050 44100 48000 96000)' \
'-b+[Bits per sample]:bits:(8 16 24 32)' \
'-l+[Leader silence length]:seconds:' \
'*:file:_files'
;;

copy)
_arguments -s \
$global_opts \
'-0[BASIC program]' \
'-1[BASIC data file]' \
'-2[Machine-language program]' \
'-3[Text editor source file]' \
'-a[ASCII data]' \
'-b[Binary data]' \
'-g[Write gaps]' \
'-n[No gaps]' \
'-d+[Load address]:address:' \
'-e+[Execution address]:address:' \
'-l[Translate line endings]' \
'-t[Entokenize BASIC text]' \
'-k[Detokenize BASIC program]' \
'-s[Encode Motorola S-record]' \
'-f[Decode Motorola S-record]' \
'-c[Concatenate machine-language segments]' \
'-p[Honor global start position]' \
'*:file:_files'
;;

dir)
_arguments -s \
$global_opts \
'*:image:_files'
;;

dump)
_arguments -s \
$global_opts \
'-a[dump output in assembler format (hex)]' \
'-b[dump output in assembler format (binary)]' \
"-c[don't display ASCII character data]" \
'-e[dump output in C format]' \
"-t[don't display header]" \
"-h[don't display header (DEPRECATED)]" \
"-l[don't display line label/count]" \
'-z[decode DECB binary]' \
'*:file:_files'
;;

dumpblock)
_arguments -s \
$global_opts \
'-h[Show help]' \
'*:image:_files'
;;

fstat)
_arguments -s \
$global_opts \
'*:file:_files'
;;

leader)
_arguments -s \
$global_opts \
'*:wave file:_files'
;;
case)
_message "unknown cecb command: $cmd"
;;
esac
;;
esac
}

_cecb "$@"
91 changes: 91 additions & 0 deletions decb/decb-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Bash completion for the `decb` ToolShed command (DECB File Tools Executive)
# Source this file (e.g. from ~/.bashrc) or drop it in
# /etc/bash_completion.d/ or /usr/local/etc/bash_completion.d/

_decb()
{
local cur prev words cword
_init_completion || return

local commands="
attr
binbust
copy
dir
dsave
dskini
free
fstat
hdbconv
kill
list
rename
"

# Complete command name
if [[ $cword -eq 1 ]]; then
COMPREPLY=( $(compgen -W "$commands" -- "$cur") )
return
fi

local cmd="${words[1]}"

case "$cmd" in
attr)
COMPREPLY=( $(compgen -W \
"-0 -1 -2 -3 -a -b" -- "$cur") )
;;

binbust)
_filedir
;;

copy)
COMPREPLY=( $(compgen -W \
"-0 -1 -2 -3 -a -b -l -r -t -c" -- "$cur") )
if [[ "$cur" != -* ]]; then
_filedir
fi
;;

dir|free|kill|fstat|list)
if [[ "$cur" != -* ]]; then
_filedir
fi
;;

dsave)
COMPREPLY=( $(compgen -W \
"-b= -e -l -t -r" -- "$cur") )
if [[ "$cur" != -* ]]; then
_filedir
fi
;;

dskini)
COMPREPLY=( $(compgen -W \
"-3 -4 -8 -h -n -s" -- "$cur") )
if [[ "$cur" != -* ]]; then
_filedir
fi
;;

hdbconv)
COMPREPLY=( $(compgen -W \
"-2 -5" -- "$cur") )
if [[ "$cur" != -* ]]; then
_filedir
fi
;;

rename)
_filedir
;;

*)
COMPREPLY=( $(compgen -W "-g" -- "$cur") )
;;
esac
}

complete -F _decb decb
Loading
Loading