mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-28 02:53:30 +00:00
# What does this PR do? when executing a sub-command like `llama model` the improper help text, sub-commands, and flags are displayed. each command group needs to have `.set_defaults` to display this info properly before: ``` llama model usage: llama [-h] {model,stack,download,verify-download} ... Welcome to the Llama CLI options: -h, --help show this help message and exit subcommands: {model,stack,download,verify-download} ``` after: ``` llama model usage: llama model [-h] {download,list,prompt-format,describe,verify-download} ... Work with llama models options: -h, --help show this help message and exit model_subcommands: {download,list,prompt-format,describe,verify-download} ``` Signed-off-by: Charlie Doern <cdoern@redhat.com>
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
import argparse
|
|
from importlib.metadata import version
|
|
|
|
from llama_stack.cli.subcommand import Subcommand
|
|
|
|
from .build import StackBuild
|
|
from .configure import StackConfigure
|
|
from .list_apis import StackListApis
|
|
from .list_providers import StackListProviders
|
|
from .run import StackRun
|
|
|
|
|
|
class StackParser(Subcommand):
|
|
def __init__(self, subparsers: argparse._SubParsersAction):
|
|
super().__init__()
|
|
self.parser = subparsers.add_parser(
|
|
"stack",
|
|
prog="llama stack",
|
|
description="Operations for the Llama Stack / Distributions",
|
|
)
|
|
|
|
self.parser.add_argument(
|
|
"--version",
|
|
action="version",
|
|
version=f"{version('llama-stack')}",
|
|
)
|
|
|
|
self.parser.set_defaults(func=lambda args: self.parser.print_help())
|
|
|
|
subparsers = self.parser.add_subparsers(title="stack_subcommands")
|
|
|
|
# Add sub-commands
|
|
StackBuild.create(subparsers)
|
|
StackConfigure.create(subparsers)
|
|
StackListApis.create(subparsers)
|
|
StackListProviders.create(subparsers)
|
|
StackRun.create(subparsers)
|