Skip to content

Commit

Permalink
fixup! cmd/archive: add --archive-stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
roobre committed Jun 18, 2024
1 parent 358b28d commit b77ab02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions cmd/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type cmdArchive struct {
gs *state.GlobalState

archiveOut string
archiveStdout bool
excludeEnvVars bool
}

Expand Down Expand Up @@ -41,7 +40,7 @@ func (c *cmdArchive) run(cmd *cobra.Command, args []string) error {
arc.Env = nil
}

if c.archiveStdout {
if c.archiveOut == "-" {
return arc.Write(c.gs.Stdout)
}

Expand All @@ -62,8 +61,10 @@ func (c *cmdArchive) flagSet() *pflag.FlagSet {
flags.SortFlags = false
flags.AddFlagSet(optionFlagSet())
flags.AddFlagSet(runtimeOptionFlagSet(false))
flags.StringVarP(&c.archiveOut, "archive-out", "O", c.archiveOut, "archive output filename")
flags.BoolVar(&c.archiveStdout, "archive-stdout", false, "output archive to stdout")
flags.StringVarP(
&c.archiveOut, "archive-out", "O", c.archiveOut,
"archive output filename. The special value - will cause the archive to be output to stdout.",
)
flags.BoolVarP(
&c.excludeEnvVars,
"exclude-env-vars",
Expand Down
2 changes: 1 addition & 1 deletion cmd/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func TestArchiveStdout(t *testing.T) {
ts := tests.NewGlobalTestState(t)
require.NoError(t, fsext.WriteFile(ts.FS, filepath.Join(ts.Cwd, fileName), testScript, 0o644))

ts.CmdArgs = []string{"k6", "archive", "--archive-stdout", fileName}
ts.CmdArgs = []string{"k6", "archive", "-O", "-", fileName}

newRootCommand(ts.GlobalState).execute()

Expand Down

0 comments on commit b77ab02

Please sign in to comment.