Skip to content

Commit e473bd3

Browse files
committed
Add USAGE documentation
1 parent 50212c6 commit e473bd3

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed

USAGE.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@
8686
* [Add an existing issue as a card to a column](#add-an-existing-issue-as-a-card-to-a-column)
8787
* [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)
8888
* [Move a card to the bottom of another column](Move-a-card-to-the-bottom-of-another-column)
89+
* [Gists](#gists)
90+
* [Getting gists](#getting-gists)
91+
* [Download a gist](#download-a-gist)
92+
* [Fork a gist](#fork-a-gist)
93+
* [Creating a gist](#creating-a-gist)
94+
* [Removing a gist](#removing-a-gist)
95+
* [Updating a gist](#updating-a-gist)
96+
* [Starring a gist](#starring-a-gist)
97+
* [Getting gist comments](#getting-gist-comments)
98+
* [Adding a gist comment](#adding-a-gist-comment)
99+
* [Changing a gist comment](#changing-a-gist-comment)
100+
* [Removing a gist comment](#removing-a-gist-comment)
89101
* [Advanced](#advanced)
90102
* [Migrating blog comments to GitHub issues](#migrating-blog-comments-to-github-issues)
91103

@@ -728,6 +740,170 @@ Move-GitHubProjectCard -Card 4 -ColumnId 6 -Bottom
728740

729741
----------
730742

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

733909
#### Migrating blog comments to GitHub issues

0 commit comments

Comments
 (0)