Skip to content

Commit

Permalink
Merge pull request #72 from bgilbert/input
Browse files Browse the repository at this point in the history
main: accept input filename as bare argument; deprecate --input
  • Loading branch information
bgilbert authored Jan 29, 2020
2 parents d57b40d + 02214d7 commit 3f9554c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ podman pull quay.io/coreos/fcct:release
podman run -i --rm quay.io/coreos/fcct:release --pretty --strict < your_config.fcc > transpiled_config.ign

# Run fcct using files.
podman run --rm -v /path/to/your_config.fcc:/config.fcc:z quay.io/coreos/fcct:release --pretty --strict --input /config.fcc > transpiled_config.ign
podman run --rm -v /path/to/your_config.fcc:/config.fcc:z quay.io/coreos/fcct:release --pretty --strict /config.fcc > transpiled_config.ign
```

### Writing and using Fedora CoreOS Configs
Expand All @@ -53,7 +53,7 @@ In this above file, you'll want to set the `ssh-rsa AAAAB3NzaC1yc...` line to be
If we take this file and give it to `fcct`:

```
$ ./bin/amd64/fcct --input example.yaml
$ ./bin/amd64/fcct example.yaml
{"ignition":{"config":{"replace":{"source":null,"verification":{}}},"security":{"tls":{}},"timeouts":{},"version":"3.0.0"},"passwd":{"users":[{"name":"core","sshAuthorizedKeys":["ssh-rsa ssh-rsa AAAAB3NzaC1yc..."]}]},"storage":{},"systemd":{}}
```
Expand Down
15 changes: 15 additions & 0 deletions internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,25 @@ func main() {
pflag.BoolVarP(&options.Strict, "strict", "s", false, "fail on any warning")
pflag.BoolVarP(&options.Pretty, "pretty", "p", false, "output formatted json")
pflag.StringVar(&input, "input", "", "read from input file instead of stdin")
pflag.Lookup("input").Deprecated = "specify filename directly on command line"
pflag.Lookup("input").Hidden = true
pflag.StringVarP(&output, "output", "o", "", "write to output file instead of stdout")

pflag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [options] [input-file]\n", os.Args[0])
fmt.Fprintf(os.Stderr, "Options:\n")
pflag.PrintDefaults()
}
pflag.Parse()

args := pflag.Args()
if len(args) == 1 && input == "" {
input = args[0]
} else if len(args) > 0 {
pflag.Usage()
os.Exit(2)
}

if helpFlag {
pflag.Usage()
os.Exit(0)
Expand Down

0 comments on commit 3f9554c

Please sign in to comment.