Skip to content

Commit abede4c

Browse files
committed
Add USAGE documentation
1 parent a263b0d commit abede4c

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed

USAGE.md

+176
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@
8383
* [Add an existing issue as a card to a column](#add-an-existing-issue-as-a-card-to-a-column)
8484
* [Move a card to be after a certain card in the same column](Move-a-card-to-be-after-a-certain-card-in-the-same-column)
8585
* [Move a card to the bottom of another column](Move-a-card-to-the-bottom-of-another-column)
86+
* [Gists](#gists)
87+
* [Getting gists](#getting-gists)
88+
* [Download a gist](#download-a-gist)
89+
* [Fork a gist](#fork-a-gist)
90+
* [Creating a gist](#creating-a-gist)
91+
* [Removing a gist](#removing-a-gist)
92+
* [Updating a gist](#updating-a-gist)
93+
* [Starring a gist](#starring-a-gist)
94+
* [Getting gist comments](#getting-gist-comments)
95+
* [Adding a gist comment](#adding-a-gist-comment)
96+
* [Changing a gist comment](#changing-a-gist-comment)
97+
* [Removing a gist comment](#removing-a-gist-comment)
8698
* [Advanced](#advanced)
8799
* [Migrating blog comments to GitHub issues](#migrating-blog-comments-to-github-issues)
88100

@@ -709,6 +721,170 @@ Move-GitHubProjectCard -Card 4 -ColumnId 6 -Bottom
709721

710722
----------
711723

724+
### Gists
725+
726+
#### Getting gists
727+
```powershell
728+
# There are many options here:
729+
730+
# 1. Getting all gists for the current authenticated user:
731+
Get-GitHubGist
732+
733+
# 1b. Getting all gists for the current authenticated user that were updated in the past 6 days.
734+
Get-GitHubGist -Since ((Get-Date).AddDays(-6))
735+
736+
# 2. Get all starred gists for the current authenticated user
737+
Get-GitHubGist -Starred
738+
739+
# 3. Get all public gists for a specific user
740+
Get-GitHubGist -UserName 'octocat'
741+
742+
# 4. Get all public gists (well, the first 3000):
743+
Get-GitHubGist -Public
744+
745+
# 5. Get a specific gist
746+
Get-GitHubGist -Gist '6cad326836d38bd3a7ae'
747+
748+
# 5a. List all commits for a specific gist
749+
Get-GitHubGist -Gist '6cad326836d38bd3a7ae' -Commits
750+
751+
# 5b. Get a gist at a specific commit (Sha)
752+
Get-GitHubGist -Gist '6cad326836d38bd3a7ae' -Sha 'de5b9b59d1f28206e8d646c7c8025e9809d0ed73'
753+
754+
# 5c. Get all of the forks for a gist
755+
Get-GitHubGist -Gist '6cad326836d38bd3a7ae' -Forks
756+
```
757+
758+
#### Download a gist
759+
```powershell
760+
Get-GitHubGist -Gist '6cad326836d38bd3a7ae' -Path 'c:\users\octocat\downloads\gist\'
761+
```
762+
763+
#### Fork a gist
764+
```powershell
765+
Fork-GitHubGist -Gist '6cad326836d38bd3a7ae'
766+
```
767+
768+
#### Creating a gist
769+
```powershell
770+
# You can create a gist by specifying a single file's content in-line...
771+
New-GitHubGist -FileName 'foo.txt' -Content 'foo content'
772+
773+
# or by providing one or more files that should be part of the gist
774+
New-GitHubGist -File @('c:\files\foo.txt', 'c:\files\bar.txt')
775+
@('c:\files\foo.txt', 'c:\files\bar.txt') | New-GitHubGist
776+
```
777+
778+
#### Removing a gist
779+
```powershell
780+
Remove-GitHubGist -Gist '6cad326836d38bd3a7ae'
781+
```
782+
783+
#### Updating a gist
784+
```powershell
785+
$gist = New-GitHubGist -FileName 'foo.txt' -Content 'content'
786+
787+
# The main method to use is Set-GitHubGist, however it is quite complicated.
788+
$params = @{
789+
Description = 'new description' # modifies the description of the gist
790+
Update = @{
791+
'foo.txt' = @{
792+
fileName = 'alpha.txt' # Will rename foo.txt -> alpha.txt
793+
content = 'updated content' # and will also update its content
794+
}
795+
'bar.txt' = @{
796+
filePath = 'c:\files\bar.txt' # Will upload the content of bar.txt to the gist.
797+
}
798+
}
799+
Delete = @('bar.txt')
800+
Force = $true # avoid confirmation prompting due to the deletion
801+
}
802+
803+
Set-GitHubGist -Gist $gist.id @params
804+
805+
# Therefore, you can use simpler helper methods to accomplish atomic tasks
806+
Set-GistHubGistFile -Gist $gist.id -FileName 'foo.txt' -Content 'updated content'
807+
808+
# This will update the text in the existing file 'foo.txt' and add the file 'bar.txt'
809+
$gist | Set-GitHubGistFile -File ('c:\files\foo.txt', 'c:\files\bar.txt')
810+
811+
Rename-GistHubGistFile -Gist $gist.id -FileName 'foo.txt' -NewName 'bar.txt'
812+
813+
$gist | Remove-GitHubGistFile -FileName 'bar.txt' -Force
814+
815+
```
816+
817+
#### Starring a gist
818+
```powershell
819+
$gistId = '6cad326836d38bd3a7ae'
820+
821+
# All of these options will star the same gist
822+
Star-GitHubGist -Gist $gistId
823+
Add-GitHubGistStar -Gist $gistId
824+
Set-GitHubGistStar -Gist $gistId -Star
825+
Get-GitHubGist -Gist $gistId | Star-GitHubGist
826+
827+
# All of these options will unstar the same gist
828+
Unstar-GitHubGist -Gist $gistId
829+
Remove-GitHubGistStar -Gist $gistId
830+
Set-GitHubGistStar -Gist $gistId
831+
Set-GitHubGistStar -Gist $gistId -Star:$false
832+
Get-GitHubGist -Gist $gistId | Unstar-GitHubGist
833+
834+
# All of these options will tell you if you have starred a gist
835+
Test-GitHubGistStar -Gist $gistId
836+
Get-GitHubGist -Gist $gistId | Test-GitHubGistStar
837+
```
838+
839+
#### Getting gist comments
840+
```powershell
841+
$gistId = '6cad326836d38bd3a7ae'
842+
$commentId = 1507813
843+
844+
# You can get all comments for a gist with any of these options:
845+
Get-GitHubGistComment -Gist $gistId
846+
Get-GitHubGist -Gist $gistId | Get-GitHubGistComment
847+
848+
# You can retrieve an individual comment like this:
849+
Get-GitHubGistComment -Gist $gistId -Comment $commentId
850+
```
851+
852+
#### Adding a gist comment
853+
```powershell
854+
$gistId = '6cad326836d38bd3a7ae'
855+
856+
New-GitHubGistComment -Gist $gistId -Body 'Hello World'
857+
858+
# or with the pipeline
859+
Get-GitHubGist -Gist $gistId | New-GitHubGistComment -Body 'Hello World'
860+
```
861+
862+
#### Changing a gist comment
863+
```powershell
864+
$gistId = '6cad326836d38bd3a7ae'
865+
$commentId = 1507813
866+
867+
Set-GitHubGistComment -Gist $gistId -Comment $commentId -Body 'Updated comment'
868+
869+
# or with the pipeline
870+
Get-GitHubGist -Gist $gistId -Comment $commentId | Set-GitHubGistComment -Body 'Updated comment'
871+
```
872+
873+
#### Removing a gist comment
874+
```powershell
875+
$gistId = '6cad326836d38bd3a7ae'
876+
$commentId = 1507813
877+
878+
# If you don't specify -Force, it will prompt for confirmation before it will delete the comment
879+
880+
Remove-GitHubGistComment -Gist $gistId -Comment $commentId -Force
881+
882+
# or with the pipeline
883+
Get-GitHubGist -Gist $gistId -Comment $commentId | Remove-GitHubGistComment -Force
884+
```
885+
886+
----------
887+
712888
### Advanced
713889

714890
#### Migrating blog comments to GitHub issues

0 commit comments

Comments
 (0)