Skip to content

Commit 3507e9d

Browse files
committed
add pen up height to cli
1 parent 67130b9 commit 3507e9d

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

elkplot/cli.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
from typing import Optional
12
import click
23

34
import elkplot
45

56

67
@click.group()
7-
def cli():
8-
...
8+
def cli(): ...
99

1010

1111
@cli.command()
@@ -21,15 +21,25 @@ def home():
2121

2222

2323
@cli.command()
24-
def up():
24+
@click.argument("height", type=float, required=False)
25+
def up(height: Optional[float] = None):
2526
"""Lift the pen off the page"""
26-
elkplot.Device().pen_up()
27+
if height is not None:
28+
device = elkplot.Device(pen_up_position=height)
29+
else:
30+
device = elkplot.Device()
31+
device.pen_up()
2732

2833

2934
@cli.command()
30-
def down():
35+
@click.argument("height", type=float, required=False)
36+
def down(height: Optional[float] = None):
3137
"""Bring the pen down onto the page"""
32-
elkplot.Device().pen_down()
38+
if height is not None:
39+
device = elkplot.Device(pen_up_position=height)
40+
else:
41+
device = elkplot.Device()
42+
device.pen_down()
3343

3444

3545
@cli.command()

0 commit comments

Comments
 (0)