forked from jrnl-org/jrnl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.py
50 lines (37 loc) · 1.39 KB
/
cli.py
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
#!/usr/bin/env python
"""
jrnl
license: GPLv3, see LICENSE.md for more details.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import logging
import sys
from .jrnl import run
from .args import parse_args
def configure_logger(debug=False):
if not debug:
logging.disable()
return
logging.basicConfig(
level=logging.DEBUG, format="%(levelname)-8s %(name)-12s %(message)s",
)
logging.getLogger("parsedatetime").setLevel(logging.INFO)
logging.getLogger("keyring.backend").setLevel(logging.ERROR)
def cli(manual_args=None):
try:
if manual_args is None:
manual_args = sys.argv[1:]
args = parse_args(manual_args)
configure_logger(args.debug)
logging.debug("Parsed args: %s", args)
return run(args)
except KeyboardInterrupt:
return 1