eepprog.py: Implement Click CategorizedGroup
This commit is contained in:
parent
d9a7cb401d
commit
d17d5341ce
2 changed files with 74 additions and 4 deletions
|
|
@ -4,9 +4,10 @@ import click
|
|||
import serial.tools.list_ports
|
||||
|
||||
from helpers import CliContext, Logger, EepromProgrammer
|
||||
from helpers.click import CategorizedGroup
|
||||
|
||||
|
||||
@click.group()
|
||||
@click.group(cls=CategorizedGroup)
|
||||
@click.option('--device', '-d', default='/dev/ttyUSB0', show_default=True,
|
||||
metavar='DEVICE', help="Set the serial device")
|
||||
@click.option('--baud', '-b', default=38400, show_default=True,
|
||||
|
|
@ -29,7 +30,7 @@ def eepprog(ctx: click.Context, device: str, baud: int, verbose: bool) -> None:
|
|||
ctx.call_on_close(eeprom_programmer.close)
|
||||
|
||||
|
||||
@eepprog.command('hello', short_help='Say hello. :)')
|
||||
@eepprog.command('hello', category='Test commands', short_help='Say hello. :)')
|
||||
@click.pass_obj
|
||||
def hello(context: CliContext) -> None:
|
||||
"""
|
||||
|
|
@ -46,7 +47,7 @@ def hello(context: CliContext) -> None:
|
|||
context.logger.success('yay!')
|
||||
|
||||
|
||||
@eepprog.command('test', short_help="Send INIT command to the programmer and read answer")
|
||||
@eepprog.command('test', category='Test commands', short_help="Send INIT command to the programmer and read answer")
|
||||
@click.pass_obj
|
||||
def test(context: CliContext) -> None:
|
||||
"""
|
||||
|
|
@ -57,7 +58,7 @@ def test(context: CliContext) -> None:
|
|||
context.eeprom_programmer.test_command()
|
||||
|
||||
|
||||
@eepprog.command('list-devices', short_help="List available serial ports")
|
||||
@eepprog.command('list-devices', category='Helper commands', short_help="List available serial ports")
|
||||
@click.pass_obj
|
||||
def list_devices(context: CliContext) -> None:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue