-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
123 lines (99 loc) · 2.59 KB
/
cli.py
File metadata and controls
123 lines (99 loc) · 2.59 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import argparse
import json
import os
import shutil
import site
import sys
import textwrap
import time
# import warnings
import yaml
from colorama import Fore, init
from .config import Config, config_reader, interactive, generate_config
from .utils import initialize
from .test import sync
home = os.path.expanduser("~")
init(autoreset=True)
def options():
'''
Parsing the Arguments here
'''
ap = argparse.ArgumentParser(
prog="syncboostnote",
usage="%(prog)s [options]",
formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent('''SyncBoostNotes
=======================================
- A CLI to Sync your BoostNotes Notes -
=======================================
'''))
ap.add_argument(
"-l",
"--location",
required=False,
help="Location of the BoostNotes local storage.",
default=os.path.join(home, 'Boostnote'))
# ap.add_argument(
# "-ini",
# "--init",
# required=False,
# help="Initialise the CLI",
# default=False)
ap.add_argument(
"--sync",
# dest=False,
action='store_true'
)
ap.add_argument(
"-co",
"--config",
required=False,
help="Location of the config.yaml/config.yml file",
default=False)
ap.add_argument(
"-g",
"--generate",
help="Generate config.yaml file for ya",
action='store_true'
)
ap.add_argument(
"-i",
"--interactive",
required=False,
help="Get an Interactive prompt to fill the forms.",
default=False)
ap.set_defaults(feature=False)
return vars(ap.parse_args())
def starter(args):
'''
Sets the Config for the installation
'''
if args['sync']:
sync()
elif args['generate']:
return generate_config()
elif args['interactive']:
return interactive()
elif args['location']:
# Location is at the default and the user wants default shit.
initialize({
"BOOSTNOTE_PATH": args['location'],
"SHIELDS": True,
"SHIELDS_TYPE": "for-the-badge",
"FREQUENCY": "hourly",
"TIME": 1200
})
elif args['config']:
print(args['generate'])
conf = yaml.load(
open(args['generate'], 'r'),
Loader=yaml.Loader
)
initialize(conf)
else:
# ! Weird
raise Exception('Weird')
def run_as_command():
args = options()
starter(args)
run_as_command()