forked from igniteflow/codebase-python-api-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodebase
More file actions
executable file
·42 lines (33 loc) · 1.1 KB
/
codebase
File metadata and controls
executable file
·42 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
import pprint
import sys
from codebase.client import CodeBaseAPI
if __name__ == "__main__":
"""
Simple command-line interface to the Codebase API. Example usage:
codebase myproject all_notes 6
Arguments:
1. project name
2. api function name
3. args to pass to the api function
"""
if len(sys.argv) == 1:
# if no args then print available API methods
for name in dir(CodeBaseAPI):
if name[0] != '_' and name[0].islower():
print name
else:
# make the API call
# TODO use something more sensible like argparse
if not len(sys.argv) >= 3:
print('Usage: codebase [project name] [api method]\n e.g. codebase myproject statuses')
exit(1)
# TODO if only one arg given, then assume its a global command e.g. 'projects'
project = sys.argv[1]
command = sys.argv[2]
args = sys.argv[3:]
codebase = CodeBaseAPI(
project=project,
)
response = getattr(codebase, command)(*args)
pprint.pprint(response)