Skip to content

Commit ff5bdeb

Browse files
committed
fix(cmd): propperly utilize --no-color and --no-prompt
1 parent 1fe5469 commit ff5bdeb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

cmd/print.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ func printItems(w io.Writer, items []fmt.Stringer, offset int) (err error) {
6868
}
6969

7070
func printToPager(w io.Writer, buf *bytes.Buffer) (err error) {
71+
if noPrompt {
72+
fmt.Fprintln(w, buf.String())
73+
return
74+
}
7175
// TODO (ramfox): This is POSIX specific, need to expand!
7276
envPager := os.Getenv("PAGER")
7377
if ok := doesCommandExist(envPager); !ok {

cmd/qri.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ https://qri.io
2727
2828
Feedback, questions, bug reports, and contributions are welcome!
2929
https://github.com/qri-io/qri/issues`,
30+
PersistentPreRun: func(cmd *cobra.Command, args []string) {
31+
noColor, err := cmd.Flags().GetBool("no-color")
32+
if err == nil && noColor {
33+
setNoColor(noColor)
34+
}
35+
noPrompt, err := cmd.Flags().GetBool("no-prompt")
36+
if err == nil && noPrompt {
37+
setNoPrompt(noPrompt)
38+
}
39+
},
3040
}
3141

3242
qriPath, ipfsPath := pf()

0 commit comments

Comments
 (0)