0

I have been trying to find methods to upload code to Gist (returning the id/url of the created Gist to be able to reference, both anonymously and publicly/privately using a git account) and to be able download/edit the contents/description of those Gists from the commandline natively with PowerShell.

There are various good solutions for this for other environments (this question, for example, is very similar in scope but for bash, and the answers there cover bash, python, ruby etc Upload a file to a Gist with bash). I would appreciate pointers or solutions for this as in many searches elsewhere I have found no working methods to natively achieve something like this with PowerShell. Being able to upload/download/edit/share code as Gists similar to that question (but natively with PowerShell on Windows) would be of broad usefulness I think.

torek
  • 448,244
  • 59
  • 642
  • 775
YorSubs
  • 3,194
  • 7
  • 37
  • 60
  • OK, but this is not a PowerShell problem/issue, which is what we are here to assist with. You really should show what you've tried and show what errors you are encountering, otherwise, you are asking folks to write code for you from scratch. Many here will tell you that StackOverflow is not a code / script writing service. Are you saying, that you search for 'powershell gist', and what was returned did not give you what you are after or a starting point? – postanote Nov 23 '19 at 06:09
  • I've been searching for days in fact and found nothing that gives me a starting point to build this. The link that I provided shows alternatives in bash / ruby / python (where the criticism of 'StackOverflow not a code / script writing service' should also apply, right? https://stackoverflow.com/questions/26484337/upload-a-file-to-a-gist-with-bash ). I am asking the question in as honest a way as that question (I use PowerShell a lot, but I do not have the knowledge to approach what others may have already achieved routinely). – YorSubs Nov 23 '19 at 07:48

1 Answers1

1

You might use the Posh-Gist module as starting point.

In short: Gists are created via Rest API, in powershell you use the invoke-restmethod cmdlet.

Github provides a Rest API, which is well documented.

Peter Schneider
  • 2,879
  • 1
  • 14
  • 17
  • Many thanks. It does not cover various of the things that we saw on the bash thread (such as git account for public/private), but a great starting point. Hopefully, more answers out there (the equivalent bash question saw dozens of answers with people pouring in extra details, while I was criticised merely for asking this question!). I like the ideas on that Posh-Gist module very much, though tying it to an ISE module is awkward for me (I'd prefer standalone scripts). I can't upvote or mark your comment as accepted due to the truly bizarre "reputation" system on here. Thanks again. – YorSubs Nov 23 '19 at 14:58