-
Notifications
You must be signed in to change notification settings - Fork 25
ArgumentValidatingCommand
Nicolas Couture edited this page Apr 19, 2026
·
1 revision
ArgumentValidatingCommand is used for commands that require a specific set of arguments to execute successfully.
It compares the provided arguments against a required list and triggers different callbacks based on the result.
import MockSSH
def save_config(instance):
instance.writeln("Configuration saved successfully.")
def show_usage(instance):
instance.writeln("Usage: commit force")
# This command will only succeed if the user types 'commit force'
commit_cmd = MockSSH.ArgumentValidatingCommand(
"commit", # Base command name
[save_config], # Success callbacks
[show_usage], # Failure callbacks
"force" # Required arguments
)- name: The trigger command string.
- success_callbacks: A list of functions called if arguments match.
- failure_callbacks: A list of functions called if arguments do not match.
- *args: One or more strings representing the exact expected arguments.