|
6 | 6 | "io"
|
7 | 7 | "os"
|
8 | 8 | "os/exec"
|
9 |
| - "strings" |
10 | 9 |
|
11 | 10 | "github.com/ulikunitz/xz"
|
12 | 11 | "zenhack.net/go/sandstorm/capnp/spk"
|
@@ -80,57 +79,33 @@ func archiveBytesFromReader(r io.Reader, manifestBytes, bridgeCfgBytes []byte) [
|
80 | 79 |
|
81 | 80 | // Flags for the pack subcommand.
|
82 | 81 | type packFlags struct {
|
83 |
| - // The flags proper: |
84 |
| - pkgDef, imageFile, image, outFilename, altAppKey string |
| 82 | + // flags shared with the build command: |
| 83 | + buildFlags |
85 | 84 |
|
86 |
| - // The two logical parts of pkgDef: |
87 |
| - pkgDefFile, pkgDefVar string |
| 85 | + // other flags: |
| 86 | + imageFile, image string |
88 | 87 | }
|
89 | 88 |
|
90 |
| -func (p *packFlags) Register() { |
91 |
| - flag.StringVar(&p.pkgDef, |
92 |
| - "pkg-def", |
93 |
| - "sandstorm-pkgdef.capnp:pkgdef", |
94 |
| - "The location from which to read the package definition, of the form\n"+ |
95 |
| - "<def-file>:<name>. <def-file> is the name of the file to look in,\n"+ |
96 |
| - "and <name> is the name of the constant defining the package\n"+ |
97 |
| - "definition.", |
98 |
| - ) |
99 |
| - flag.StringVar(&p.imageFile, |
| 89 | +func (f *packFlags) Register() { |
| 90 | + f.buildFlags.Register() |
| 91 | + flag.StringVar(&f.imageFile, |
100 | 92 | "imagefile", "",
|
101 | 93 | "File containing Docker image to convert (output of \"docker save\")",
|
102 | 94 | )
|
103 |
| - flag.StringVar(&p.image, |
| 95 | + flag.StringVar(&f.image, |
104 | 96 | "image", "",
|
105 | 97 | "Name of the image to convert (fetched from the running docker daemon).",
|
106 | 98 | )
|
107 |
| - flag.StringVar(&p.outFilename, |
108 |
| - "out", "", |
109 |
| - "File name of the resulting spk (default inferred from package metadata)", |
110 |
| - ) |
111 |
| - flag.StringVar(&p.altAppKey, |
112 |
| - "appkey", "", |
113 |
| - "Sign the package with the specified app key, instead of the one\n"+ |
114 |
| - "defined in the package definition. This can be useful if e.g.\n"+ |
115 |
| - "you do not have access to the key with which the final app is\n"+ |
116 |
| - "published.") |
117 | 99 | }
|
118 | 100 |
|
119 |
| -func (p *packFlags) Parse() { |
120 |
| - flag.Parse() |
121 |
| - if p.imageFile == "" && p.image == "" { |
| 101 | +func (f *packFlags) Parse() { |
| 102 | + f.buildFlags.Parse() |
| 103 | + if f.imageFile == "" && f.image == "" { |
122 | 104 | usageErr("Missing option: -image or -imagefile")
|
123 | 105 | }
|
124 |
| - if p.imageFile != "" && p.image != "" { |
| 106 | + if f.imageFile != "" && f.image != "" { |
125 | 107 | usageErr("Only one of -image or -imagefile may be specified.")
|
126 | 108 | }
|
127 |
| - |
128 |
| - pkgDefParts := strings.SplitN(p.pkgDef, ":", 2) |
129 |
| - if len(pkgDefParts) != 2 { |
130 |
| - usageErr("-pkg-def's argument must be of the form <def-file>:<name>") |
131 |
| - } |
132 |
| - p.pkgDefFile = pkgDefParts[0] |
133 |
| - p.pkgDefVar = pkgDefParts[1] |
134 | 109 | }
|
135 | 110 |
|
136 | 111 | func packCmd() {
|
|
0 commit comments