-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify the CLI code and make help prettier
Fixes #34 Signed-off-by: Fabrice Normandin <[email protected]>
- Loading branch information
Showing
7 changed files
with
78 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
from dataclasses import dataclass | ||
from typing import Union | ||
|
||
from simple_parsing import subparsers | ||
from simple_parsing import ArgumentParser | ||
|
||
from sarc.cli.acquire.allocations import AcquireAllocations | ||
from sarc.cli.acquire.jobs import AcquireJobs | ||
from sarc.cli.acquire.storages import AcquireStorages | ||
|
||
|
||
@dataclass | ||
class Acquire: | ||
command: Union[AcquireAllocations, AcquireJobs, AcquireStorages] = subparsers( | ||
{ | ||
"allocations": AcquireAllocations, | ||
"jobs": AcquireJobs, | ||
"storages": AcquireStorages, | ||
} | ||
def add_acquire_commands(parser: ArgumentParser): | ||
subparsers = parser.add_subparsers( | ||
title="subcommand", | ||
description="Acquire subcommand", | ||
dest="subcommand_name", | ||
required=True, | ||
) | ||
allocations_parser = subparsers.add_parser( | ||
"allocations", help="Acquire allocations help" | ||
) | ||
allocations_parser.add_arguments(AcquireAllocations, dest="subcommand") | ||
|
||
jobs_parser = subparsers.add_parser("jobs", help="Acquire jobs help") | ||
jobs_parser.add_arguments(AcquireJobs, dest="subcommand") | ||
|
||
def execute(self) -> int: | ||
return self.command.execute() | ||
storages_parser = subparsers.add_parser("storages", help="Acquire storages help") | ||
storages_parser.add_arguments(AcquireStorages, dest="subcommand") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
from dataclasses import dataclass | ||
from typing import Union | ||
|
||
from simple_parsing import subparsers | ||
from simple_parsing import ArgumentParser | ||
|
||
from sarc.cli.db.init import DbInit | ||
|
||
|
||
@dataclass | ||
class Db: | ||
"""this is help""" | ||
|
||
command: Union[DbInit] = subparsers( | ||
{ | ||
"init": DbInit, | ||
} | ||
def add_db_commands(parser: ArgumentParser): | ||
subparsers = parser.add_subparsers( | ||
title="subcommand", | ||
description="subcommand description", | ||
dest="subcommand_name", | ||
required=True, | ||
) | ||
|
||
def execute(self) -> int: | ||
return self.command.execute() | ||
db_init_subparser = subparsers.add_parser("init", help="Initialize the DB") | ||
db_init_subparser.add_arguments(DbInit, dest="subcommand") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
@dataclass | ||
class DbInit: | ||
"""Initializes the database.""" | ||
|
||
url: Optional[str] | ||
database: Optional[str] | ||
|
||
|