You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We don't output any ANSI escape sequences in NO_COLOR mode from our code, but we do invoke the Survey library for prompts, and it appears that it doesn't respect NO_COLOR. We can try to fix this.
Do you think it's still appropriate to render terminal prompts in NO_COLOR mode? We can disable all color-related ANSI sequences, but there might be other escape sequences involved in these prompts, such as ones for redrawing parts of the screen.
The other alternative would be to disable prompts entirely in NO_COLOR mode and rely on all information being supplied via flags.
I think there are two main cases to consider, automation and accessibility. There are obvious subcases as well for example automation by means of scraping the accessible output, but the two cases cover the technical point as far as I can see.
Automation. Just like you are doing for gh auth login, it is important to be able to specify everything via commandline parameters. I notice for example in pr_create.go that you don't call titleBodySurvey() until you have checked !isWeb && !autofill && interactive , which suggests you can relatively easily make sure the non-interactive mode fills in up to 100% of parameters from the commandline. (In addition it would be also be possible to call Survey to fill in those parameters that have not been supplied on the commandline but that makes the logic more complicated because you can't just test for interactivity in a boolean way.)
Accessibility. There are many highly accessible utilities that have user interaction, and many of them use libreadline. libreadline is more boring than Survey. A library that doesn't respect NO_COLOR is a library that has given no thought to accessibility, and that is a problem no matter how exciting it can make the output.
For your encouragement, if you do enable 100% of parameters to be optionally passed by commandline, and if you implement this in a general manner so that help can automatically be generated by recursively visiting for every parameter supported, then you have created something new. Because a version of "gh help" that recursively lists all parameters is a map to github that other applications can build on to do things you haven't thought of yet.
In summary, I think the problem is with Survey not the use of Survey.
A library that doesn't respect NO_COLOR is a library that has given no thought to accessibility
but I think Survey is worse than that. It doesn't seem to consider anything about the terminal at all, for example, export TERM=vt52 makes no difference to gh's behaviour.
and if you implement this in a general manner so that help can automatically be generated by recursively visiting for every parameter supported, then you have created something new.
Thank you! Would you please elaborate on how you imagined this help system to work, or with an example? We're looking how to improve our help output this month, so any feedback would be great.
Re: accessibility: we definitely aim to provide flags for any inputs that are otherwise prompted for. In fact, that should already be the experience with the latest released version of gh. GitHub CLI should be always accessible in non-interactive mode since we're aware that Survey right now is not accessible when it comes to selecting an option from a list, and for the reasons with terminal detection/support that you already pointed out.
Re: accessibility: we definitely aim to provide flags for any inputs that are otherwise prompted for.
I was also suggesting the opposite: that you prompt for any inputs that have not been specified on the commandline.
This leads to better results for the end user. For example if I have a script that can set up 3 parameters because it has that knowledge, and just prompt for a 4th from the user, that will reduce errors and frustration. Often there is a situation where partial automation is possible.
Would you please elaborate on how you imagined this help system to work, or with an example? We're looking how to improve our help output this month, so any feedback would be great.
Right now gh has a manual help system because I have to specify both the command and the subcommand:
gh <command> <subcommand> --help
In fact, gh modules collectively have the knowledge to supply both command and subcommand and could make it available:
gh <command> --help-recursive
would list all of the subcommands and attributes of these subcommands, and any sub-subcommands that may exist one day.
gh --help-recursive
would list every single command and parameter.
Since cli's whole purpose is to be a commandline, then I think this feature should be an important part of testing, and it lends itself to unit tests. When developing a new command, we would first start by writing the help function.
Finally, cli is entirely based around a parse tree, so I think the only way to do this in a fully machine-readable/automatable manner would be to have these commands:
And this is how gh can futureproof itself. You will have designed an interface to github that is self-documenting and which maps both to human-usable commandline parameters but also machine-readable commandline parameters, and with a little care, what is effectively a machine-readable programmable API specification.
It is quite likely that the current Go code for cli won't be in use five years from now (look at Hub - it is deprecated already even though it has more functionality than gh.) But if you get this new functional description for github right it will be maintained and in use for many years to come, probably decades.
Activity
mislav commentedon Aug 5, 2020
Thanks for reporting! This is indeed a bug.
We don't output any ANSI escape sequences in NO_COLOR mode from our code, but we do invoke the Survey library for prompts, and it appears that it doesn't respect NO_COLOR. We can try to fix this.
Do you think it's still appropriate to render terminal prompts in NO_COLOR mode? We can disable all color-related ANSI sequences, but there might be other escape sequences involved in these prompts, such as ones for redrawing parts of the screen.
The other alternative would be to disable prompts entirely in NO_COLOR mode and rely on all information being supplied via flags.
danshearer commentedon Aug 5, 2020
I think there are two main cases to consider, automation and accessibility. There are obvious subcases as well for example automation by means of scraping the accessible output, but the two cases cover the technical point as far as I can see.
Automation. Just like you are doing for gh auth login, it is important to be able to specify everything via commandline parameters. I notice for example in pr_create.go that you don't call
titleBodySurvey()until you have checked!isWeb && !autofill && interactive, which suggests you can relatively easily make sure the non-interactive mode fills in up to 100% of parameters from the commandline. (In addition it would be also be possible to call Survey to fill in those parameters that have not been supplied on the commandline but that makes the logic more complicated because you can't just test for interactivity in a boolean way.)Accessibility. There are many highly accessible utilities that have user interaction, and many of them use libreadline. libreadline is more boring than Survey. A library that doesn't respect NO_COLOR is a library that has given no thought to accessibility, and that is a problem no matter how exciting it can make the output.
For your encouragement, if you do enable 100% of parameters to be optionally passed by commandline, and if you implement this in a general manner so that help can automatically be generated by recursively visiting for every parameter supported, then you have created something new. Because a version of "gh help" that recursively lists all parameters is a map to github that other applications can build on to do things you haven't thought of yet.
In summary, I think the problem is with Survey not the use of Survey.
danshearer commentedon Aug 5, 2020
I said above
but I think Survey is worse than that. It doesn't seem to consider anything about the terminal at all, for example,
export TERM=vt52makes no difference to gh's behaviour.On the other hand, you can see from the discussion of colour in Ncurses at https://invisible-island.net/ncurses/ncurses.faq.html that terminal color is quite complicated and library authors should not pretend it doesn't exist.
mislav commentedon Aug 5, 2020
Thank you! Would you please elaborate on how you imagined this help system to work, or with an example? We're looking how to improve our help output this month, so any feedback would be great.
Re: accessibility: we definitely aim to provide flags for any inputs that are otherwise prompted for. In fact, that should already be the experience with the latest released version of gh. GitHub CLI should be always accessible in non-interactive mode since we're aware that Survey right now is not accessible when it comes to selecting an option from a list, and for the reasons with terminal detection/support that you already pointed out.
danshearer commentedon Aug 5, 2020
I was also suggesting the opposite: that you prompt for any inputs that have not been specified on the commandline.
This leads to better results for the end user. For example if I have a script that can set up 3 parameters because it has that knowledge, and just prompt for a 4th from the user, that will reduce errors and frustration. Often there is a situation where partial automation is possible.
danshearer commentedon Aug 5, 2020
Right now gh has a manual help system because I have to specify both the command and the subcommand:
In fact, gh modules collectively have the knowledge to supply both command and subcommand and could make it available:
would list all of the subcommands and attributes of these subcommands, and any sub-subcommands that may exist one day.
would list every single command and parameter.
Since cli's whole purpose is to be a commandline, then I think this feature should be an important part of testing, and it lends itself to unit tests. When developing a new command, we would first start by writing the help function.
Finally, cli is entirely based around a parse tree, so I think the only way to do this in a fully machine-readable/automatable manner would be to have these commands:
And this is how gh can futureproof itself. You will have designed an interface to github that is self-documenting and which maps both to human-usable commandline parameters but also machine-readable commandline parameters, and with a little care, what is effectively a machine-readable programmable API specification.
It is quite likely that the current Go code for cli won't be in use five years from now (look at Hub - it is deprecated already even though it has more functionality than gh.) But if you get this new functional description for github right it will be maintained and in use for many years to come, probably decades.