function::set_long_arg - Linux


function::set_long_arg allows customizing the behavior of the function build-in command by setting a long option.


function::set_long_arg [--name name] [--value value] [--type type] [--default-value default-value] [--docstring docstring] [--help-group help-group]


  • –name: Name of the long option to be created.
  • –value: Value to be assigned to the option.
  • –type: Type of the option to be set.
  • –default-value: Default value for the option.
  • –docstring: Documentation string for the option.
  • –help-group: Help group to which the option belongs.


Simple Usage

function::set_long_arg --name "verbose" --value "--verbose" --type "bool" --default-value "false" --docstring "Enable verbose output" --help-group "Options"

Setting Multiple Options

function::set_long_arg --name "port" --value "--port" --type "int" --default-value "80" --docstring "Set the port number" --help-group "Network"
function::set_long_arg --name "timeout" --value "--timeout" --type "duration" --default-value "30s" --docstring "Set the timeout" --help-group "Network"

Common Issues

  • Avoid using existing long option names to prevent conflicts.
  • Ensure the type and default value are compatible to avoid errors.


Combine with function::dump to introspect the set long arguments:

declare -A opts
function::dump opts

Related Commands

  • type: Get information about defined functions and types.
  • help: Display help for functions, types, and variables.