Created
February 5, 2022 21:30
-
-
Save spouliot/a0762413a59f67904f6a1c5a60276299 to your computer and use it in GitHub Desktop.
My first gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using SimpleGist; | |
| if (args.Length == 0) { | |
| Console.WriteLine ("Usage: SimpleGist.exe <file> [<file2> ...]"); | |
| return 1; | |
| } | |
| var token = Environment.GetEnvironmentVariable ("GITHUB_OAUTH_TOKEN"); | |
| if (token is null) { | |
| var home = Environment.GetEnvironmentVariable ("HOME"); | |
| if (home is not null) | |
| token = File.ReadAllText (Path.Combine (home, ".gist")); | |
| } | |
| GistClient.OAuthToken = token; | |
| GistRequest request = new () { | |
| Description = "My first gist", | |
| Public = true, | |
| }; | |
| foreach (var arg in args) { | |
| if (!File.Exists (arg)) { | |
| Console.WriteLine ($"File {arg} does not exist"); | |
| return 1; | |
| } | |
| request.AddFile (arg, File.ReadAllText (arg)); | |
| } | |
| var response = await GistClient.CreateAsync (request); | |
| Console.WriteLine (response.Url); | |
| return 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment