Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
goFrendiAsgard committed Dec 9, 2023
1 parent 6e4eb13 commit 7b05aa0
Show file tree
Hide file tree
Showing 19 changed files with 621 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/concepts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# Concepts

- [Tasks](tasks/README.md)
- [Tasks](task/README.md)
- [Task Group](task-group.md)
- [Task Input](task-input.md)
- [Task Inputs](task-input/README.md)
- [Task Env](task-env.md)
- [Task EnvFile](task-env-file.md)
- [Template](template.md)
Expand Down
86 changes: 86 additions & 0 deletions docs/concepts/task-input/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
🔖 [Table of Contents](../../README.md) / [Concepts](../README.md)

# Task Input

Sometimes, you need some user inputs to run your Tasks.

Zrb allows you to set `inputs` for your Task; either by:

- Using `inputs` parameter.
- Using `add_input` method.
- Using `insert_input` method.

All Task Input should comply with `AnyInput` interface.

Currently, there are some built-in inputs you can use:

- [Input](./input.md)
- [BoolInput](./bool-input.md)
- [ChoiceInput](./choice-input.md)
- [FloatInput](./float-input.md)
- [IntInput](./int-input.md)
- [PasswordInput](./password-input.md)
- [StrInput](./str-input.md)

Here, you will see the technical specification of `AnyInput`

# Technical Specification

<!--start-doc-->
## `AnyInput`

Abstract base class representing a generalized input specification.
This class serves as a template for creating various input types,
providing a standardized interface for input handling and processing.

### `AnyInput.get_default`

Obtains the default value of the input.

__Returns:__

`Any`: The default value of the input. The type can be any, depending on the input specification.

### `AnyInput.get_name`

Retrieves the name of the input.

__Returns:__

`str`: The name of the input.

### `AnyInput.get_options`

Provides a mapping (dictionary) representing the input.

__Returns:__

`Mapping[str, Any]`: A dictionary where keys are option names and values are the corresponding details.

### `AnyInput.get_param_decl`

Fetches a list of parameter option associated with the input (i.e., `-f` or `--file`).

__Returns:__

`List[str]`: A list containing strings of parameter options.

### `AnyInput.is_hidden`

Checks whether the input value is meant to be hidden from view or output.

__Returns:__

`bool`: True if the input is hidden, False otherwise.

### `AnyInput.should_render`

Determines whether or not the input should be rendered.

__Returns:__

`bool`: True if the input should be rendered, False otherwise.

<!--end-doc-->

🔖 [Table of Contents](../../README.md) / [Concepts](../README.md)
100 changes: 100 additions & 0 deletions docs/concepts/task-input/bool-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
🔖 [Table of Contents](../../README.md) / [Concepts](../README.md) / [Task Input](README.md)

# BoolInput

# Technical Specification

<!--start-doc-->
## `BoolInput`

A concrete implementation of the AnyInput abstract base class, representing a specific type of task input.
This class allows for the creation of interactive and configurable inputs for tasks, with various attributes
to customize its behavior and appearance.

__Attributes:__

- `name` (`str`): The name of the input, used as a unique identifier.
- `shortcut` (`Optional[str]`): An optional single-character shortcut for the input.
- `default` (`Optional[Any]`): The default value of the input.
- `description` (`Optional[str]`): A brief description of what the input is for.
- `show_default` (`Union[bool, JinjaTemplate, None]`): Determines whether the default value should be displayed.
- `prompt` (`Union[bool, str]`): The prompt text to be displayed when asking for the input.
- `confirmation_prompt` (`Union[bool, str]`): A prompt for confirmation if required.
- `prompt_required` (`bool`): Indicates whether a prompt is required.
- `hide_input` (`bool`): If True, the input value will be hidden (e.g., for passwords).
- `is_flag` (`Optional[bool]`): Specifies whether the input is a flag.
- `flag_value` (`Optional[Any]`): The value to be used if the input is a flag.
- `multiple` (`bool`): Allows multiple values for this input if True.
- `count` (`bool`): If True, counts the occurrences of the input.
- `allow_from_autoenv` (`bool`): If True, allows values to be automatically sourced from the environment.
- `type` (`Optional[Any]`): The expected type of the input value.
- `hidden` (`bool`): If True, the input is hidden and not rendered.
- `show_choices` (`bool`): Indicates whether to show available choices for the input.
- `show_envvar` (`bool`): If True, shows the corresponding environment variable.
- `nargs` (`int`): Number of arguments expected for this input.
- `should_render` (`bool`): Determines whether the input should be rendered.

__Examples:__

```python
from zrb import Input, Task
task = Task(
name='task',
inputs=[
Input(name='delay', default=10, description='Delay')
]
)
```


### `BoolInput.get_default`

Obtains the default value of the input.

__Returns:__

`Any`: The default value of the input. The type can be any, depending on the input specification.

### `BoolInput.get_name`

Retrieves the name of the input.

__Returns:__

`str`: The name of the input.

### `BoolInput.get_options`

Provides a mapping (dictionary) representing the input.

__Returns:__

`Mapping[str, Any]`: A dictionary where keys are option names and values are the corresponding details.

### `BoolInput.get_param_decl`

Fetches a list of parameter option associated with the input (i.e., `-f` or `--file`).

__Returns:__

`List[str]`: A list containing strings of parameter options.

### `BoolInput.is_hidden`

Checks whether the input value is meant to be hidden from view or output.

__Returns:__

`bool`: True if the input is hidden, False otherwise.

### `BoolInput.should_render`

Determines whether or not the input should be rendered.

__Returns:__

`bool`: True if the input should be rendered, False otherwise.

<!--end-doc-->

🔖 [Table of Contents](../../README.md) / [Concepts](../README.md) / [Task Input](README.md)
100 changes: 100 additions & 0 deletions docs/concepts/task-input/choice-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
🔖 [Table of Contents](../../README.md) / [Concepts](../README.md) / [Task Input](README.md)

# ChoiceInput

# Technical Specification

<!--start-doc-->
## `ChoiceInput`

A concrete implementation of the AnyInput abstract base class, representing a specific type of task input.
This class allows for the creation of interactive and configurable inputs for tasks, with various attributes
to customize its behavior and appearance.

__Attributes:__

- `name` (`str`): The name of the input, used as a unique identifier.
- `shortcut` (`Optional[str]`): An optional single-character shortcut for the input.
- `default` (`Optional[Any]`): The default value of the input.
- `description` (`Optional[str]`): A brief description of what the input is for.
- `show_default` (`Union[bool, JinjaTemplate, None]`): Determines whether the default value should be displayed.
- `prompt` (`Union[bool, str]`): The prompt text to be displayed when asking for the input.
- `confirmation_prompt` (`Union[bool, str]`): A prompt for confirmation if required.
- `prompt_required` (`bool`): Indicates whether a prompt is required.
- `hide_input` (`bool`): If True, the input value will be hidden (e.g., for passwords).
- `is_flag` (`Optional[bool]`): Specifies whether the input is a flag.
- `flag_value` (`Optional[Any]`): The value to be used if the input is a flag.
- `multiple` (`bool`): Allows multiple values for this input if True.
- `count` (`bool`): If True, counts the occurrences of the input.
- `allow_from_autoenv` (`bool`): If True, allows values to be automatically sourced from the environment.
- `type` (`Optional[Any]`): The expected type of the input value.
- `hidden` (`bool`): If True, the input is hidden and not rendered.
- `show_choices` (`bool`): Indicates whether to show available choices for the input.
- `show_envvar` (`bool`): If True, shows the corresponding environment variable.
- `nargs` (`int`): Number of arguments expected for this input.
- `should_render` (`bool`): Determines whether the input should be rendered.

__Examples:__

```python
from zrb import Input, Task
task = Task(
name='task',
inputs=[
Input(name='delay', default=10, description='Delay')
]
)
```


### `ChoiceInput.get_default`

Obtains the default value of the input.

__Returns:__

`Any`: The default value of the input. The type can be any, depending on the input specification.

### `ChoiceInput.get_name`

Retrieves the name of the input.

__Returns:__

`str`: The name of the input.

### `ChoiceInput.get_options`

Provides a mapping (dictionary) representing the input.

__Returns:__

`Mapping[str, Any]`: A dictionary where keys are option names and values are the corresponding details.

### `ChoiceInput.get_param_decl`

Fetches a list of parameter option associated with the input (i.e., `-f` or `--file`).

__Returns:__

`List[str]`: A list containing strings of parameter options.

### `ChoiceInput.is_hidden`

Checks whether the input value is meant to be hidden from view or output.

__Returns:__

`bool`: True if the input is hidden, False otherwise.

### `ChoiceInput.should_render`

Determines whether or not the input should be rendered.

__Returns:__

`bool`: True if the input should be rendered, False otherwise.

<!--end-doc-->

🔖 [Table of Contents](../../README.md) / [Concepts](../README.md) / [Task Input](README.md)
Loading

0 comments on commit 7b05aa0

Please sign in to comment.