-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforgor.fish
More file actions
executable file
·66 lines (60 loc) · 1.63 KB
/
forgor.fish
File metadata and controls
executable file
·66 lines (60 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env fish
set -l _version "0.0.3"
set -x commands "help" "I forgor everything..."
source ./dictionary.fish
for file in (ls ./forgors/*.fish)
source $file
end
function _completions
dict_entries $commands
end
function _subcommands
dict_keys $commands
end
function _help -a subcommand -d "Print human readable list of subcommands"
if test -n "$subcommand"
set -l description (dict_get $subcommand $commands)
if test -n "$description"
echo " "$description
else
printf "Unknown subcommand: '%s'\n" $subcommand
echo "Type 'forgor help' for usage."
end
else
printf "forgor %s\n" $_version
echo "Ethan Christensen <ethanchristensen01@gmail.com>"
echo "A tool to aggregate mini commands"
echo -e "\nUSAGE:"
echo -e " forgor <SUBCOMMAND>"
echo -e "\nSUBCOMMANDS:"
for pairstring in (dict_entries $commands)
set -l cmd_desc (string split "::" $pairstring)
printf ' %s%s\n' (string pad -r -w 16 --char '-' $cmd_desc[1]) $cmd_desc[2]
end
end
end
function forgor
set -l subcommand "$argv[1]"
switch $subcommand
case ""
_help
case "help" "-h" "--help"
_help $argv[2]
case "_completions"
_completions
case "_subcommands"
_subcommands
case "*"
# Check if subcommand is in commands list
for compare_command in (dict_keys $commands)
if test $subcommand = $compare_command
forgor_$subcommand
return
end
end
echo "Unknown subcommand: '$subcommand'"
echo "Type 'forgor help' for usage."
return 1
end
end
forgor $argv