forked from ScoopInstaller/Scoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoop-help.ps1
50 lines (37 loc) · 1.1 KB
/
scoop-help.ps1
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
# Usage: scoop help <command>
# Summary: Show help for a command
param($cmd)
. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\commands.ps1"
. "$psscriptroot\..\lib\help.ps1"
reset_aliases
function print_help($cmd) {
$file = Get-Content (command_path $cmd) -raw
$usage = usage $file
$summary = summary $file
$help = help $file
if($usage) { "$usage`n" }
if($help) { $help }
}
function print_summaries {
$commands = @{}
command_files | ForEach-Object {
$command = command_name $_
$summary = summary (Get-Content (command_path $command) -raw)
if(!($summary)) { $summary = '' }
$commands.add("$command ", $summary) # add padding
}
$commands.getenumerator() | Sort-Object name | Format-Table -hidetablehead -autosize -wrap
}
$commands = commands
if(!($cmd)) {
"Usage: scoop <command> [<args>]
Some useful commands are:"
print_summaries
"Type 'scoop help <command>' to get help for a specific command."
} elseif($commands -contains $cmd) {
print_help $cmd
} else {
"scoop help: no such command '$cmd'"; exit 1
}
exit 0