Actions
Queue-based argparse extensions for ordered task execution.
This module provides custom argparse actions that accumulate parsed arguments into a shared queue dictionary and allow defining execution boundaries via task actions.
It enables building command-line interfaces where arguments are grouped and processed incrementally instead of being stored statically in a namespace.
Queue
Bases: Action
flowchart TD
src.qargparse.action.Queue[Queue]
click src.qargparse.action.Queue href "" "src.qargparse.action.Queue"
Argparse action that stores parsed arguments into a shared queue dictionary.
This action writes each parsed argument value into a dictionary stored
on the argparse namespace under the attribute defined by Q_KWARGS.
The destination name (self.dest) is used as the key and the parsed
value is stored as the corresponding value.
This action does not preserve call order. It overwrites previously stored values for the same destination key.
Source code in src/qargparse/action.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
QueueTrue
Bases: _QueueDeterministic
flowchart TD
src.qargparse.action.QueueTrue[QueueTrue]
src.qargparse.action._QueueDeterministic[_QueueDeterministic]
src.qargparse.action.Queue[Queue]
src.qargparse.action._QueueDeterministic --> src.qargparse.action.QueueTrue
src.qargparse.action.Queue --> src.qargparse.action._QueueDeterministic
click src.qargparse.action.QueueTrue href "" "src.qargparse.action.QueueTrue"
click src.qargparse.action._QueueDeterministic href "" "src.qargparse.action._QueueDeterministic"
click src.qargparse.action.Queue href "" "src.qargparse.action.Queue"
Boolean queue action that stores True.
This action behaves similarly to argparse's store_true action,
but stores the value inside the shared queue dictionary defined by
Q_KWARGS instead of directly on the namespace.
Source code in src/qargparse/action.py
73 74 75 76 77 78 79 80 81 | |
QueueFalse
Bases: _QueueDeterministic
flowchart TD
src.qargparse.action.QueueFalse[QueueFalse]
src.qargparse.action._QueueDeterministic[_QueueDeterministic]
src.qargparse.action.Queue[Queue]
src.qargparse.action._QueueDeterministic --> src.qargparse.action.QueueFalse
src.qargparse.action.Queue --> src.qargparse.action._QueueDeterministic
click src.qargparse.action.QueueFalse href "" "src.qargparse.action.QueueFalse"
click src.qargparse.action._QueueDeterministic href "" "src.qargparse.action._QueueDeterministic"
click src.qargparse.action.Queue href "" "src.qargparse.action.Queue"
Boolean queue action that stores False.
This action behaves similarly to argparse's store_false action,
but stores the value inside the shared queue dictionary defined by
Q_KWARGS instead of directly on the namespace.
Source code in src/qargparse/action.py
83 84 85 86 87 88 89 90 91 | |
Task
Bases: _QueueDeterministic
flowchart TD
src.qargparse.action.Task[Task]
src.qargparse.action._QueueDeterministic[_QueueDeterministic]
src.qargparse.action.Queue[Queue]
src.qargparse.action._QueueDeterministic --> src.qargparse.action.Task
src.qargparse.action.Queue --> src.qargparse.action._QueueDeterministic
click src.qargparse.action.Task href "" "src.qargparse.action.Task"
click src.qargparse.action._QueueDeterministic href "" "src.qargparse.action._QueueDeterministic"
click src.qargparse.action.Queue href "" "src.qargparse.action.Queue"
Special queue action that creates and registers a task boundary.
This action treats the current queue state as a completed task.
When invoked, it:
- Creates a new task entry structured as:
{task_name: collected_arguments}. - Appends this task entry to the task list stored under
Q_TASKS. - Resets the queue dictionary to an empty state.
This enables CLI patterns such as:
tool.py --a foo --b bar --run --c baz --run
Where each --run marks a boundary and triggers collection of
the previously accumulated arguments as a separate task.
Source code in src/qargparse/action.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |