This repository was archived by the owner on Feb 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
73 lines (59 loc) · 2.03 KB
/
main.go
File metadata and controls
73 lines (59 loc) · 2.03 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Command ocibuild deals with manipulation of OCI/Docker images and layers as regular files.
package main
import (
"context"
"fmt"
"os"
"github.com/datawire/dlib/dlog"
"github.com/google/go-containerregistry/pkg/logs"
"github.com/spf13/cobra"
"github.com/datawire/ocibuild/pkg/cliutil"
)
var (
argparser = &cobra.Command{
Use: "ocibuild {[flags]|SUBCOMMAND...}",
Short: "Manipulate OCI/Docker images and layers as regular files",
Args: cliutil.WrapPositionalArgs(cliutil.OnlySubcommands),
RunE: cliutil.RunSubcommands,
SilenceErrors: true, // main() will handle this after .ExecuteContext() returns
SilenceUsage: true, // our FlagErrorFunc will handle it
CompletionOptions: cobra.CompletionOptions{ //nolint:exhaustivestruct
DisableDefaultCmd: true,
},
}
argparserImage = &cobra.Command{
Use: "image {[flags]|SUBCOMMAND...}",
Short: "Manipulate complete images",
Args: cliutil.WrapPositionalArgs(cliutil.OnlySubcommands),
RunE: cliutil.RunSubcommands,
}
argparserLayer = &cobra.Command{
Use: "layer {[flags]|SUBCOMMAND...}",
Short: "Manipulate individual layers for use in an image",
Args: cliutil.WrapPositionalArgs(cliutil.OnlySubcommands),
RunE: cliutil.RunSubcommands,
}
argparserPython = &cobra.Command{
Use: "python {[flags]|SUBCOMMAND...}",
Short: "Interact with Python without the target environment",
Args: cliutil.WrapPositionalArgs(cliutil.OnlySubcommands),
RunE: cliutil.RunSubcommands,
}
)
func init() {
argparser.SetFlagErrorFunc(cliutil.FlagErrorFunc)
argparser.SetHelpTemplate(cliutil.HelpTemplate)
argparser.AddCommand(argparserImage)
argparser.AddCommand(argparserLayer)
argparser.AddCommand(argparserPython)
}
func main() {
ctx := context.Background()
logs.Warn = dlog.StdLogger(ctx, dlog.LogLevelWarn)
logs.Progress = dlog.StdLogger(ctx, dlog.LogLevelInfo)
logs.Debug = dlog.StdLogger(ctx, dlog.LogLevelDebug)
if err := argparser.ExecuteContext(ctx); err != nil {
fmt.Fprintf(argparser.ErrOrStderr(), "%s: error: %v\n", argparser.CommandPath(), err)
os.Exit(1)
}
}