Files
Scoop/libexec/scoop-help.ps1
2022-04-21 21:34:26 +08:00

44 lines
1009 B
PowerShell

# Usage: scoop help <command>
# Summary: Show help for a command
param($cmd)
function print_help($cmd) {
$file = Get-Content (command_path $cmd) -raw
$usage = usage $file
$summary = summary $file
$help = scoop_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