291 lines
7.3 KiB
Go
291 lines
7.3 KiB
Go
package help
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"reg/internal/i18n"
|
|
)
|
|
|
|
var msgHelp = &i18n.Msg{
|
|
EN: `help — detailed help for a command.
|
|
|
|
Usage:
|
|
reg help <command>
|
|
reg help <group> <subcommand>
|
|
|
|
Description:
|
|
Prints detailed description, usage line, flags, notes and examples
|
|
for the specified command.
|
|
|
|
Groups and commands:
|
|
repo list, repo tree, repo tags, repo info, repo manifest,
|
|
repo delete, repo find, repo latest, repo prune, repo stats, repo verify
|
|
blob info, blob get, blob delete
|
|
image pull, image push, image copy, image config, image files, image history
|
|
manifest rm, manifest tag, manifest untag, manifest exist, manifest digest
|
|
auth login, auth logout, auth status, auth migrate, auth token, auth whoami
|
|
referrer list
|
|
config get, config set, config unset, config list
|
|
export, import
|
|
ping, capabilities
|
|
help
|
|
|
|
Top-level aliases (short forms) are also available for:
|
|
pull, push, copy, rm, tag, untag, exist, digest,
|
|
login, logout, token, whoami.
|
|
|
|
Examples:
|
|
reg help repo list
|
|
reg help repo prune
|
|
reg help repo stats
|
|
reg help repo verify
|
|
reg help blob get
|
|
reg help image pull
|
|
reg help image config
|
|
reg help image files
|
|
reg help image history
|
|
reg help manifest rm
|
|
reg help auth login
|
|
reg help auth status
|
|
reg help auth migrate
|
|
reg help referrer list
|
|
reg help config set
|
|
reg help pull (alias of image pull)
|
|
reg help rm (alias of manifest rm)
|
|
reg help login (alias of auth login)
|
|
reg help blob info
|
|
reg help export
|
|
`,
|
|
RU: `help — подробная справка по команде.
|
|
|
|
Использование:
|
|
reg help <command>
|
|
reg help <group> <subcommand>
|
|
|
|
Описание:
|
|
Выводит подробное описание, строку использования, флаги, нюансы
|
|
и примеры для указанной команды.
|
|
|
|
Группы и команды:
|
|
repo list, repo tree, repo tags, repo info, repo manifest,
|
|
repo delete, repo find, repo latest, repo prune, repo stats, repo verify
|
|
blob info, blob get, blob delete
|
|
image pull, image push, image copy, image config, image files, image history
|
|
manifest rm, manifest tag, manifest untag, manifest exist, manifest digest
|
|
auth login, auth logout, auth status, auth migrate, auth token, auth whoami
|
|
referrer list
|
|
config get, config set, config unset, config list
|
|
export, import
|
|
ping, capabilities
|
|
help
|
|
|
|
Алиасы верхнего уровня (короткие формы) для:
|
|
pull, push, copy, rm, tag, untag, exist, digest,
|
|
login, logout, token, whoami.
|
|
|
|
Примеры:
|
|
reg help repo list
|
|
reg help repo prune
|
|
reg help repo stats
|
|
reg help repo verify
|
|
reg help blob get
|
|
reg help image pull
|
|
reg help image config
|
|
reg help image files
|
|
reg help image history
|
|
reg help manifest rm
|
|
reg help auth login
|
|
reg help auth status
|
|
reg help auth migrate
|
|
reg help referrer list
|
|
reg help config set
|
|
reg help pull (алиас image pull)
|
|
reg help rm (алиас manifest rm)
|
|
reg help login (алиас auth login)
|
|
reg help blob info
|
|
reg help export
|
|
`,
|
|
}
|
|
|
|
// Show печатает подробную справку по указанной команде.
|
|
func Show(args []string) error {
|
|
switch args[0] {
|
|
case "repo":
|
|
if len(args) < 2 {
|
|
printRepo()
|
|
return nil
|
|
}
|
|
switch args[1] {
|
|
case "list":
|
|
printRepoList()
|
|
case "tree":
|
|
printRepoTree()
|
|
case "tags":
|
|
printRepoTags()
|
|
case "info":
|
|
printRepoInfo()
|
|
case "manifest":
|
|
printRepoManifest()
|
|
case "delete":
|
|
printRepoDelete()
|
|
case "find":
|
|
printRepoFind()
|
|
case "latest":
|
|
printRepoLatest()
|
|
case "prune":
|
|
printRepoPrune()
|
|
case "stats":
|
|
printRepoStats()
|
|
case "verify":
|
|
printRepoVerify()
|
|
default:
|
|
return fmt.Errorf("%s", MsgUnknownRepoSub.F(args[1]))
|
|
}
|
|
case "blob":
|
|
if len(args) < 2 {
|
|
printBlob()
|
|
return nil
|
|
}
|
|
switch args[1] {
|
|
case "info":
|
|
printBlobInfo()
|
|
case "get":
|
|
printBlobGet()
|
|
case "delete":
|
|
printBlobDelete()
|
|
default:
|
|
return fmt.Errorf("%s", MsgUnknownBlobSub.F(args[1]))
|
|
}
|
|
case "image":
|
|
if len(args) < 2 {
|
|
printImage()
|
|
return nil
|
|
}
|
|
switch args[1] {
|
|
case "pull":
|
|
printPull()
|
|
case "push":
|
|
printPush()
|
|
case "copy":
|
|
printCopy()
|
|
case "config":
|
|
printImageConfig()
|
|
case "files":
|
|
printImageFiles()
|
|
case "history":
|
|
printImageHistory()
|
|
default:
|
|
return fmt.Errorf("%s", MsgUnknownImageSub.F(args[1]))
|
|
}
|
|
case "manifest":
|
|
if len(args) < 2 {
|
|
printManifest()
|
|
return nil
|
|
}
|
|
switch args[1] {
|
|
case "rm":
|
|
printRm()
|
|
case "tag":
|
|
printTag()
|
|
case "untag":
|
|
printUntag()
|
|
case "exist":
|
|
printExist()
|
|
case "digest":
|
|
printDigest()
|
|
default:
|
|
return fmt.Errorf("%s", MsgUnknownManifestSub.F(args[1]))
|
|
}
|
|
case "auth":
|
|
if len(args) < 2 {
|
|
printAuth()
|
|
return nil
|
|
}
|
|
switch args[1] {
|
|
case "login":
|
|
printAuthLogin()
|
|
case "logout":
|
|
printAuthLogout()
|
|
case "status":
|
|
printAuthStatus()
|
|
case "migrate":
|
|
printAuthMigrate()
|
|
case "token":
|
|
printToken()
|
|
case "whoami":
|
|
printWhoami()
|
|
default:
|
|
return fmt.Errorf("%s", MsgUnknownAuthSub.F(args[1]))
|
|
}
|
|
case "referrer":
|
|
if len(args) < 2 {
|
|
printReferrer()
|
|
return nil
|
|
}
|
|
switch args[1] {
|
|
case "list":
|
|
printReferrerList()
|
|
default:
|
|
return fmt.Errorf("%s", MsgUnknownReferrerSub.F(args[1]))
|
|
}
|
|
case "config":
|
|
if len(args) < 2 {
|
|
printConfig()
|
|
return nil
|
|
}
|
|
switch args[1] {
|
|
case "get":
|
|
printConfigGet()
|
|
case "set":
|
|
printConfigSet()
|
|
case "unset":
|
|
printConfigUnset()
|
|
case "list":
|
|
printConfigList()
|
|
default:
|
|
return fmt.Errorf("%s", MsgUnknownConfigSub.F(args[1]))
|
|
}
|
|
case "pull":
|
|
printPull()
|
|
case "push":
|
|
printPush()
|
|
case "copy":
|
|
printCopy()
|
|
case "rm":
|
|
printRm()
|
|
case "tag":
|
|
printTag()
|
|
case "untag":
|
|
printUntag()
|
|
case "exist":
|
|
printExist()
|
|
case "digest":
|
|
printDigest()
|
|
case "login":
|
|
printAuthLogin()
|
|
case "logout":
|
|
printAuthLogout()
|
|
case "token":
|
|
printToken()
|
|
case "whoami":
|
|
printWhoami()
|
|
case "export":
|
|
printExport()
|
|
case "import":
|
|
printImport()
|
|
case "ping":
|
|
printPing()
|
|
case "capabilities":
|
|
printCapabilities()
|
|
case "help":
|
|
printHelp()
|
|
default:
|
|
return fmt.Errorf("%s", MsgUnknownCommand.F(args[0]))
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func printHelp() {
|
|
fmt.Print(msgHelp.String())
|
|
}
|