Add the pager config option
This commit is contained in:
parent
c643778701
commit
f6dd1bcd0a
4 changed files with 20 additions and 3 deletions
|
|
@ -51,12 +51,14 @@ func main() {
|
|||
os.Exit(2)
|
||||
}
|
||||
|
||||
prompt, _ := cfg.Get("", "prompt")
|
||||
|
||||
if prompt == config.PromptsDisabled {
|
||||
if prompt, _ := cfg.Get("", "prompt"); prompt == config.PromptsDisabled {
|
||||
cmdFactory.IOStreams.SetNeverPrompt(true)
|
||||
}
|
||||
|
||||
if pager, _ := cfg.Get("", "pager"); pager != "" {
|
||||
cmdFactory.IOStreams.SetPager(pager)
|
||||
}
|
||||
|
||||
expandedArgs := []string{}
|
||||
if len(os.Args) > 0 {
|
||||
expandedArgs = os.Args[1:]
|
||||
|
|
|
|||
|
|
@ -180,6 +180,15 @@ func NewBlankRoot() *yaml.Node {
|
|||
Kind: yaml.ScalarNode,
|
||||
Value: PromptsEnabled,
|
||||
},
|
||||
{
|
||||
HeadComment: "A pager program to send command output to. Example value: less",
|
||||
Kind: yaml.ScalarNode,
|
||||
Value: "pager",
|
||||
},
|
||||
{
|
||||
Kind: yaml.ScalarNode,
|
||||
Value: "",
|
||||
},
|
||||
{
|
||||
HeadComment: "Aliases allow you to create nicknames for gh commands",
|
||||
Kind: yaml.ScalarNode,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ func Test_defaultConfig(t *testing.T) {
|
|||
editor:
|
||||
# When to interactively prompt. This is a global config that cannot be overriden by hostname. Supported values: enabled, disabled
|
||||
prompt: enabled
|
||||
# A pager program to send command output to. Example value: less
|
||||
pager:
|
||||
# Aliases allow you to create nicknames for gh commands
|
||||
aliases:
|
||||
co: pr checkout
|
||||
|
|
|
|||
|
|
@ -92,6 +92,10 @@ func (s *IOStreams) IsStderrTTY() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (s *IOStreams) SetPager(cmd string) {
|
||||
s.pagerCommand = cmd
|
||||
}
|
||||
|
||||
func (s *IOStreams) StartPager() error {
|
||||
if s.pagerCommand == "" || !s.IsStdoutTTY() {
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue