Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions 142 pkg/cmd/accessibility/accessibility.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package accessibility

import (
"fmt"

"github.com/MakeNowJust/heredoc"
"github.com/cli/cli/v2/internal/browser"
"github.com/cli/cli/v2/internal/text"
"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/cli/cli/v2/pkg/iostreams"
"github.com/spf13/cobra"
)

const (
webURL = "https://accessibility.github.com/conformance/cli/"
)

type AccessibilityOptions struct {
IO *iostreams.IOStreams
Browser browser.Browser
Web bool
}

func NewCmdAccessibility(f *cmdutil.Factory) *cobra.Command {
opts := AccessibilityOptions{
IO: f.IOStreams,
Browser: f.Browser,
}

cmd := &cobra.Command{
Use: "accessibility",
Aliases: []string{"a11y"},
Short: "Learn about GitHub CLI's accessibility experiences",
Long: longDescription(opts.IO),
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
if opts.Web {
if opts.IO.IsStdoutTTY() {
fmt.Fprintf(opts.IO.ErrOut, "Opening %s in your browser.\n", text.DisplayURL(webURL))
}
return opts.Browser.Browse(webURL)
}

return cmd.Help()
},
Example: heredoc.Doc(`
# Open the GitHub Accessibility site in your browser
$ gh accessibility --web

# Display color using customizable, 4-bit accessible colors
$ gh config set accessible_colors enabled

# Use input prompts without redrawing the screen
$ gh config set accessible_prompter enabled

# Disable motion-based spinners for progress indicators in favor of text
$ gh config set spinner disabled
`),
}

cmd.Flags().BoolVarP(&opts.Web, "web", "w", false, "Open the GitHub Accessibility site in your browser")
cmdutil.DisableAuthCheck(cmd)

return cmd
}

func longDescription(io *iostreams.IOStreams) string {
cs := io.ColorScheme()
title := cs.Bold("Learn about GitHub CLI's accessibility experiences")
color := cs.Bold("Customizable and contrasting colors")
prompter := cs.Bold("Non-interactive user input prompting")
spinner := cs.Bold("Text-based spinners")
feedback := cs.Bold("Join the conversation")

return heredoc.Docf(`
%[2]s

As the home for all developers, we want every developer to feel welcome in our
community and be empowered to contribute to the future of global software
development with everything GitHub has to offer including the GitHub CLI.

%[3]s

Text interfaces often use color for various purposes, but insufficient contrast
or customizability can leave some users unable to benefit.

For a more accessible experience, the GitHub CLI can use color palettes
based on terminal background appearance and limit colors to 4-bit ANSI color
palettes, which users can customize within terminal preferences.

With this new experience, the GitHub CLI provides multiple options to address
color usage:

1. The GitHub CLI will use 4-bit color palette for increased color contrast based
on dark and light backgrounds including rendering Markdown based on the
GitHub Primer design system.

To enable this experience, use one of the following methods:
- Run %[1]sgh config set accessible_colors enabled%[1]s
- Set %[1]sGH_ACCESSIBLE_COLORS=enabled%[1]s environment variable

2. The GitHub CLI will display issue and pull request labels' custom RGB colors
in terminals with true color support.

To enable this experience, use one of the following methods:
- Run %[1]sgh config set color_labels enabled%[1]s
- Set %[1]sGH_COLOR_LABELS=enabled%[1]s environment variable

%[4]s

Interactive text user interfaces manipulate the terminal cursor to redraw parts
of the screen, which can be difficult for speech synthesizers or braille displays
to accurately detect and read.

For a more accessible experience, the GitHub CLI can provide a similar experience using
non-interactive prompts for user input.

To enable this experience, use one of the following methods:
- Run %[1]sgh config set accessible_prompter enabled%[1]s
- Set %[1]sGH_ACCESSIBLE_PROMPTER=enabled%[1]s environment variable

%[5]s

Motion-based spinners communicate in-progress activity by manipulating the
terminal cursor to create a spinning effect, which may cause discomfort to users
with motion sensitivity or miscommunicate information to speech synthesizers.

For a more accessible experience, this interactivity can be disabled in favor
of text-based progress indicators.

To enable this experience, use one of the following methods:
- Run %[1]sgh config set spinner disabled%[1]s
- Set %[1]sGH_SPINNER_DISABLED=yes%[1]s environment variable

%[6]s

We invite you to join us in improving GitHub CLI accessibility by sharing your
feedback and ideas through GitHub Accessibility feedback channels:

%[7]s
`, "`", title, color, prompter, spinner, feedback, webURL)
}
12 changes: 10 additions & 2 deletions 12 pkg/cmd/root/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ func rootHelpFunc(f *cmdutil.Factory, command *cobra.Command, _ []string) {
return
}

namePadding := 12

type helpEntry struct {
Title string
Body string
Expand All @@ -135,6 +133,12 @@ func rootHelpFunc(f *cmdutil.Factory, command *cobra.Command, _ []string) {
helpEntries = append(helpEntries, helpEntry{"ALIASES", strings.Join(BuildAliasList(command, command.Aliases), ", ") + "\n"})
}

// Statically calculated padding for non-extension commands,
// longest is `gh accessibility` with 13 characters + 1 space.
//
// Should consider novel way to calculate this in the future [AF]
namePadding := 14
Comment thread
andyfeller marked this conversation as resolved.

for _, g := range GroupedCommands(command) {
var names []string
for _, c := range g.Commands {
Expand All @@ -148,6 +152,9 @@ func rootHelpFunc(f *cmdutil.Factory, command *cobra.Command, _ []string) {

if isRootCmd(command) {
var helpTopics []string
if c := findCommand(command, "accessibility"); c != nil {
helpTopics = append(helpTopics, rpad(c.Name()+":", namePadding)+c.Short)
}
if c := findCommand(command, "actions"); c != nil {
helpTopics = append(helpTopics, rpad(c.Name()+":", namePadding)+c.Short)
}
Expand Down Expand Up @@ -183,6 +190,7 @@ func rootHelpFunc(f *cmdutil.Factory, command *cobra.Command, _ []string) {
Use %[1]sgh <command> <subcommand> --help%[1]s for more information about a command.
Read the manual at https://cli.github.com/manual
Learn about exit codes using %[1]sgh help exit-codes%[1]s
Learn about accessibility experiences using %[1]sgh help accessibility%[1]s
`, "`")})

out := f.IOStreams.Out
Expand Down
2 changes: 2 additions & 0 deletions 2 pkg/cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/MakeNowJust/heredoc"
accessibilityCmd "github.com/cli/cli/v2/pkg/cmd/accessibility"
actionsCmd "github.com/cli/cli/v2/pkg/cmd/actions"
aliasCmd "github.com/cli/cli/v2/pkg/cmd/alias"
"github.com/cli/cli/v2/pkg/cmd/alias/shared"
Expand Down Expand Up @@ -122,6 +123,7 @@ func NewCmdRoot(f *cmdutil.Factory, version, buildDate string) (*cobra.Command,

// Child commands
cmd.AddCommand(versionCmd.NewCmdVersion(f, version, buildDate))
cmd.AddCommand(accessibilityCmd.NewCmdAccessibility(f))
cmd.AddCommand(actionsCmd.NewCmdActions(f))
cmd.AddCommand(aliasCmd.NewCmdAlias(f))
cmd.AddCommand(authCmd.NewCmdAuth(f))
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.