@@ -3,6 +3,7 @@ package common
33import (
44 "flag"
55 "fmt"
6+ "io"
67 "os"
78
89 "github.com/sirupsen/logrus"
@@ -12,25 +13,69 @@ import (
1213const Version = "1.0.0"
1314
1415func usage_banner () {
15- fmt .Fprintf (flag .CommandLine .Output (), `
16+ out := flag .CommandLine .Output ()
17+
18+ // Header
19+ fmt .Fprintf (out , `
1620Parallax
1721OCI image migration tool for Podman on HPC systems
1822
1923Usage:
20- parallax -migrate -image <image[:tag]> [options]
21- parallax -rmi -image <image[:tag]> [options]
24+ parallax -- migrate - -image <image[:tag]> [options]
25+ parallax -- rmi - -image <image[:tag]> [options]
2226
2327Options:
2428` )
25- flag .PrintDefaults ()
26- fmt .Fprintf (flag .CommandLine .Output (), `
29+
30+ // New flag section
31+ order := []string {
32+ "migrate" ,
33+ "rmi" ,
34+ "image" ,
35+ "podmanRoot" ,
36+ "roStoragePath" ,
37+ "mksquashfsPath" ,
38+ "log-level" ,
39+ "version" ,
40+ }
41+ for _ , name := range order {
42+ if f := flag .CommandLine .Lookup (name ); f != nil {
43+ printFlag (out , f )
44+ }
45+ }
46+
47+ // Footer
48+ fmt .Fprintf (out , `
2749Examples:
28- parallax -migrate -image ubuntu:latest
29- parallax -rmi -image alpine:3.18
50+ parallax -- migrate - -image ubuntu:latest
51+ parallax -- rmi - -image alpine:3.18
3052
3153` )
3254}
3355
56+ func printFlag (out io.Writer , f * flag.Flag ) {
57+ // double-dashed name!
58+ line := fmt .Sprintf (" --%s" , f .Name )
59+
60+ // alignment
61+ if len (f .Name ) < 8 {
62+ line += "\t "
63+ } else {
64+ line += "\t "
65+ }
66+
67+ // usage text
68+ line += f .Usage
69+
70+ // show default
71+ if def := f .DefValue ; def != "" && def != "false" {
72+ line += fmt .Sprintf (" (default %q)" , def )
73+ }
74+ // and print
75+ fmt .Fprintln (out , line )
76+ }
77+
78+
3479// Track we are being asked
3580type Operation int
3681const (
@@ -108,3 +153,4 @@ func ParseAndValidateFlags(fs *flag.FlagSet, args []string) (*CLI, error) {
108153 LogLevel : level ,
109154 }, nil
110155}
156+
0 commit comments