Command
This class provides a command-line interface to find the absolute paths for specified static files. It leverages static file finders to locate assets and can be configured to return either the first match or all matches found across searched locations. The class also supports varying levels of output verbosity to display detailed search paths and results.
Attributes
| Attribute | Type | Description |
|---|---|---|
| help | string = Finds the absolute paths for the given static file(s). | Finds the absolute paths for the given static file(s). |
| label | string = staticfile | The name of the argument used in the command line interface to represent the static file path. |
Methods
add_arguments()
@classmethod
def add_arguments(
parser: ArgumentParser
)
Configures the command-line argument parser to include a flag for controlling whether to return all matches or only the first match found for each static file.
Parameters
| Name | Type | Description |
|---|---|---|
| parser | ArgumentParser | The argument parser instance to which the '--first' flag and other base arguments will be added. |
handle_label()
@classmethod
def handle_label(
path: string,
**options: dict
) - > string
Locates the absolute filesystem paths for a specific static file label and returns a formatted string of the results based on the specified verbosity.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | The relative path of the static file to be located within the configured static file finders. |
| **options | dict | A dictionary of runtime options, including 'verbosity' for output detail and 'all' to determine if multiple matches should be returned. |
Returns
| Type | Description |
|---|---|
string | A formatted string containing the absolute paths of the discovered static files and, if verbosity is high, the list of searched locations. |