Skip to content

Commit 40dcfd6

Browse files
authored
Merge pull request cli#12710 from cli/kw/document-gist-edit-file-replacement
Add usage examples to `gh gist edit` command
2 parents 560128b + 3af5359 commit 40dcfd6

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

pkg/cmd/gist/edit/edit.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"sort"
1313
"strings"
1414

15+
"github.com/MakeNowJust/heredoc"
1516
"github.com/cli/cli/v2/api"
1617
"github.com/cli/cli/v2/internal/gh"
1718
"github.com/cli/cli/v2/internal/prompter"
@@ -58,6 +59,28 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman
5859
cmd := &cobra.Command{
5960
Use: "edit {<id> | <url>} [<filename>]",
6061
Short: "Edit one of your gists",
62+
Example: heredoc.Doc(`
63+
# Select a gist to edit interactively
64+
$ gh gist edit
65+
66+
# Edit a gist file in the default editor
67+
$ gh gist edit 1234567890abcdef1234567890abcdef
68+
69+
# Edit a specific file in the gist
70+
$ gh gist edit 1234567890abcdef1234567890abcdef --filename hello.py
71+
72+
# Replace a gist file with content from a local file
73+
$ gh gist edit 1234567890abcdef1234567890abcdef --filename hello.py hello.py
74+
75+
# Add a new file to the gist
76+
$ gh gist edit 1234567890abcdef1234567890abcdef --add newfile.py
77+
78+
# Change the description of the gist
79+
$ gh gist edit 1234567890abcdef1234567890abcdef --desc "new description"
80+
81+
# Remove a file from the gist
82+
$ gh gist edit 1234567890abcdef1234567890abcdef --remove hello.py
83+
`),
6184
Args: func(cmd *cobra.Command, args []string) error {
6285
if len(args) > 2 {
6386
return cmdutil.FlagErrorf("too many arguments")

0 commit comments

Comments
 (0)