forked from MoCo-GHE-Admin/github-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding org_list.py to list all orgs the running user belongs to (MoCo…
…-GHE-Admin#140) * Adding org_list.py to output complete list of orgs you belong to * Updating README for org_list.py
- Loading branch information
1 parent
7027a77
commit c8bd2df
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Script to list the organizations that the runner belongs to. | ||
""" | ||
|
||
from github3 import login | ||
|
||
from github_scripts import utils | ||
|
||
|
||
def parse_args(): | ||
""" | ||
Parse the command line. | ||
Detects if no PAT is given, asks for it. | ||
:return: Returns the parsed CLI datastructures. | ||
""" | ||
|
||
parser = utils.GH_ArgParser( | ||
description="Gets a list of the organizations that the user belongs to. Useful as input to scripts that take a list of orgs. Note if you have personal orgs, this will be included." | ||
) | ||
args = parser.parse_args() | ||
|
||
return args | ||
|
||
|
||
def main(): | ||
"""Get the list of orgs""" | ||
args = parse_args() | ||
|
||
gh_sess = login(token=args.token) | ||
for org in gh_sess.organizations(): | ||
print(org.login) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.