Skip to content

Commit

Permalink
reverted cli
Browse files Browse the repository at this point in the history
  • Loading branch information
soldni committed Feb 1, 2024
1 parent d1e0975 commit 93b4651
Showing 1 changed file with 1 addition and 55 deletions.
56 changes: 1 addition & 55 deletions python/dolma/cli/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import multiprocessing
import sys
from argparse import ArgumentParser, Namespace
from importlib.metadata import version
from argparse import ArgumentParser
from pathlib import Path
from typing import Any, Dict, List, Optional, Union

import smart_open
from rich.console import Console
from rich.table import Table
from yaml import safe_load

from ..core.paths import exists
Expand All @@ -33,38 +29,6 @@
}


def check_if_version_requested(options: Namespace, *_):
"""Check if the user has requested the version of the package; if so, print and exit"""

if not getattr(options, "dolma_version", False):
return

# user has requested the version; print it and exit
module_name = __name__.split(".")[0]
print(version(module_name))
sys.exit(0)


def check_if_list_commands_requested(options: Namespace, *_):
"""Check if the user has requested the list of available commands; if so, print and exit"""

if not getattr(options, "dolma_commands", False):
return

# for easy printing, create a table
table = Table(title="Dolma commands", style="bold")
table.add_column("name", justify="left", style="cyan")
table.add_column("description", justify="left", style="magenta")

# add the commands to the table with their descriptions
for command, cli in AVAILABLE_COMMANDS.items():
table.add_row(command, cli.DESCRIPTION)

# print the table and exit
Console().print(table)
sys.exit(0)


def read_config(path: Union[None, str]) -> Dict[str, Any]:
"""Read a configuration file if it exists"""
if path is None:
Expand Down Expand Up @@ -100,24 +64,6 @@ def main(argv: Optional[List[str]] = None):
type=Path,
default=None,
)
parser.add_argument(
"-v",
"--dolma-version",
action="store_true",
help="Print version and exit",
)
parser.add_argument(
"-l",
"--dolma-commands",
action="store_true",
help="Print list of available commands and exit",
)

# check if user has requested the version
check_if_version_requested(*parser.parse_known_args(argv))

# check if user has requested the list of available commands
check_if_list_commands_requested(*parser.parse_known_args(argv))

# Continue by adding subparsers and parsing the arguments
subparsers = parser.add_subparsers(dest="command")
Expand Down

0 comments on commit 93b4651

Please sign in to comment.