diff options
| author | Paul Buetow <paul@buetow.org> | 2021-09-18 14:41:25 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2021-10-02 12:26:29 +0300 |
| commit | 6506e20f6c80f4acb7434eb9dd14f784a67189cd (patch) | |
| tree | 1554831a5468729aa48c0baf3d5c9a78a8499288 /internal/clients/args.go | |
| parent | 7fbea88cf55af9b3354b4a1334e49c38d0d920fc (diff) | |
add spartan mode
Diffstat (limited to 'internal/clients/args.go')
| -rw-r--r-- | internal/clients/args.go | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/internal/clients/args.go b/internal/clients/args.go index 7ce1634..081b911 100644 --- a/internal/clients/args.go +++ b/internal/clients/args.go @@ -1,6 +1,7 @@ package clients import ( + "flag" "fmt" "os" "path/filepath" @@ -30,14 +31,35 @@ type Args struct { SSHHostKeyCallback gossh.HostKeyCallback PrivateKeyPathFile string Quiet bool + Spartan bool + NoColor bool } -// When no servers are given, connect to localhost! -func (a *Args) handleEmptyServer() { - if a.Discovery != "" || a.ServersStr != "" { - return +// Transform the arguments based on certain conditions. +func (a *Args) Transform(args []string) { + // Interpret additional args as file list. + if a.What == "" { + var files []string + for _, file := range flag.Args() { + files = append(files, file) + } + a.What = strings.Join(files, ",") + } + + if a.Spartan { + a.Quiet = true + a.NoColor = true } +} +// TransformAfterConfigFile same as Transform, but after the config file has been read. +func (a *Args) TransformAfterConfigFile() { + if a.Discovery == "" && a.ServersStr == "" { + a.handleEmptyServer() + } +} + +func (a *Args) handleEmptyServer() { fqdn, err := os.Hostname() if err != nil { logger.FatalExit(err) @@ -68,3 +90,7 @@ func (a *Args) handleEmptyServer() { a.What = strings.Join(filePaths, ",") logger.Debug("Clean file paths", a.What) } + +func (a *Args) SerializeOptions() string { + return fmt.Sprintf("quiet=%v:spartan=%v", a.Quiet, a.Spartan) +} |
