Repository navigation
Delete files in gists #7517
Description
Activity
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!
- addedmore-info-neededMore info needed from user/contributorMore info needed from user/contributorand removedneeds-triageneeds to be reviewedneeds to be reviewed
on May 31, 2023 Removal is the last one missing from the basic set of operations called CRUD, no?
Yes I think that's true. I'm not sure how it relates to my previous comment though.
How hard will it be to add this option?
I'm OK with your proposed design for it.From the docs for updating a gist:
The gist files to be updated, renamed, or deleted. Each
keymust 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
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.Reacted by Nate SmithReacted by Michele VenturiThis seems reasonable to me! The absence of this feature is an oversight and not intentional.
Reacted by Michele Venturi and William MartinSo the
gh api gistcommand can do it?
Butgh gist edit -rwould be simpler.- addedhelp wantedContributions welcomeContributions welcomeand removedmore-info-neededMore info needed from user/contributorMore info needed from user/contributor
on 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.
Yeah, be consistent with the design of other options if there aren't specific reasons for it to be different...
I'm +1 on scoping to single file deletion as well as not allowing
-rwith other flags.As discussed, this has been implemented without the interactive flow. Thanks all.
Describe the feature or problem you’d like to solve
Files can't be deleted in gists...
Proposed solution
Add the
-doption togist edit.Additional context
Interactive if no file is specified?