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
Hi @dardo82, thanks for the enhancement request. This sounds like a sensible feature to me except that gist edit already has a -d flag (so let's just pick -r / --remove-file for the moment since that's what it is called in the UI). Let me see if I've got this right:
Non-interactive mode
➜ gh gist edit {<id>|<url>} -r my_file.txt
Interactive mode
➜ gh gist edit {<id>|<url>} -r
? Select a file to delete [Use arrows to move, type to filter]
> my_file.txt about 1 minute ago
option.rb about 3 months ago
Is that what you had in mind?
I'd also love to hear a bit more about your use case, do you usually work with gists from the command line, are you scripting something, etc. Cheers!
The gist files to be updated, renamed, or deleted. Each key must match the current filename (including extension) of the targeted gist file. For example: hello.py. To delete a file, set the whole file to null. For example: hello.py : null.
I think this feature would iterating over the files in the fetched gist, and when the Filename matches the provided one, set the value in the Files map with that key to nil and then update the gist. So, I think this shouldn't be too hard (but this is the first time I've looked at this code).
I'm inclined to accept this as a reasonable enhancement and mark this as help wanted so that someone in the community can pick it up. However, since I'm new to this project, I'm going to tag @vilmibm for his opinions as he has spent more time around the gist commands.
Activity
williammartin commentedon May 31, 2023
Hi @dardo82, thanks for the enhancement request. This sounds like a sensible feature to me except that
gist editalready has a-dflag (so let's just pick-r / --remove-filefor the moment since that's what it is called in the UI). Let me see if I've got this right:Non-interactive mode
➜ gh gist edit {<id> | <url>} -r my_file.txtInteractive mode
➜ gh gist edit {<id> | <url>} -r ? Select a file to delete [Use arrows to move, type to filter] > my_file.txt about 1 minute ago option.rb about 3 months agoIs that what you had in mind?
I'd also love to hear a bit more about your use case, do you usually work with gists from the command line, are you scripting something, etc. Cheers!
dardo82 commentedon May 31, 2023
Removal is the last one missing from the basic set of operations called CRUD, no?
williammartin commentedon May 31, 2023
Yes I think that's true. I'm not sure how it relates to my previous comment though.
dardo82 commentedon May 31, 2023
How hard will it be to add this option?
I'm OK with your proposed design for it.
williammartin commentedon May 31, 2023
From the docs for updating a gist:
I think this feature would iterating over the files in the fetched gist, and when the
Filenamematches the provided one, set the value in theFilesmap with that key toniland then update the gist. So, I think this shouldn't be too hard (but this is the first time I've looked at this code).I'm inclined to accept this as a reasonable enhancement and mark this as
help wantedso that someone in the community can pick it up. However, since I'm new to this project, I'm going to tag @vilmibm for his opinions as he has spent more time around thegistcommands.vilmibm commentedon May 31, 2023
This seems reasonable to me! The absence of this feature is an oversight and not intentional.
dardo82 commentedon Jun 1, 2023
So the
gh api gistcommand can do it?But
gh gist edit -rwould be simpler.williammartin commentedon Jun 1, 2023
A couple of further questions we should answer.
What should happen if you provide the
-rflag with other flags?➜ gh gist edit {<id> | <url>} -r my_file_to_delete.txt -a my_file_to_add.txtShould we treat this as an error or try to handle it? What would we do if this were interactive?
Should we support deleting multiple files in one command?
➜ gh gist edit {<id> | <url>} -r file_1.txt -d file_2.txtProposal
Given that:
gist edit -a file_1.txt -a file_2.txtonly adds one file (silently ignoring the other, just due to how flag parsing is done)gh gist edit -f file2.txt -a file3.txtdoesn't respect both flags (-f is silently ignored)I would be inclined to scope this work to single file deletion, and an explicit error if
-ris provided with other flags.@vilmibm for any extra thoughts.
dardo82 commentedon Jun 1, 2023
Yeah, be consistent with the design of other options if there aren't specific reasons for it to be different...
vilmibm commentedon Jun 6, 2023
I'm +1 on scoping to single file deletion as well as not allowing
-rwith other flags.williammartin commentedon Jun 23, 2023
As discussed, this has been implemented without the interactive flow. Thanks all.