Skip to content

Commit

Permalink
fix(cmd): propperly utilize --no-color and --no-prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Arqu committed Apr 2, 2020
1 parent 1fe5469 commit ff5bdeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func printItems(w io.Writer, items []fmt.Stringer, offset int) (err error) {
}

func printToPager(w io.Writer, buf *bytes.Buffer) (err error) {
if noPrompt {
fmt.Fprintln(w, buf.String())
return
}
// TODO (ramfox): This is POSIX specific, need to expand!
envPager := os.Getenv("PAGER")
if ok := doesCommandExist(envPager); !ok {
Expand Down
10 changes: 10 additions & 0 deletions cmd/qri.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ https://qri.io
Feedback, questions, bug reports, and contributions are welcome!
https://github.com/qri-io/qri/issues`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
noColor, err := cmd.Flags().GetBool("no-color")
if err == nil && noColor {
setNoColor(noColor)
}
noPrompt, err := cmd.Flags().GetBool("no-prompt")
if err == nil && noPrompt {
setNoPrompt(noPrompt)
}
},
}

qriPath, ipfsPath := pf()
Expand Down

0 comments on commit ff5bdeb

Please sign in to comment.