-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotControl_CLI.py
52 lines (31 loc) · 943 Bytes
/
plotControl_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
51
52
import click
import os
#python3 plotControl_CLI.py plot /Users/marcleonard/Projects/p5/marc_circles.svg
from python.plotter import PlotControl
pc = PlotControl(interactive=True)
@click.group('cli')
def cli():
"""Manages CLI."""
@cli.command('plot')
@click.argument('file')
def plotcommand(file=None):
"""/path/to/file.svg"""
if not os.path.exists(file):
click.echo('Files does not exist. Provide full path.')
else:
click.echo('path to plot {}'.format(file))
pc.run(filename=file)
@cli.group('setup')
def setup():
"""Run Setup commands"""
@setup.command('connection')
def connection():
"""(will return the status of the plotter connection)"""
connection = pc.connection()
if connection['connected'] == False:
rv = 'No plotter found :-('
else:
rv = 'Connection found:\n{}'.format(connection)
click.echo(rv)
if __name__ == '__main__':
cli()