Skip to main content
Skip to main content

AG005: Args Declared but :args Never Called

PropertyValue
CodeAG005
SeverityError
Sincev0.1.0

Description

A function declares an args=() array but never calls :args or :usage to actually parse the arguments. The array declaration has no effect without the corresponding parse call.

Example

This triggers AG005:

my_func() {
local name
local -a args=(
'name|n' "The name"
)
# missing: :args "My function" "${@}"
echo "Hello"
}

How to Fix

Add a call to :args (or :usage if the function also has subcommands):

my_func() {
local name
local -a args=(
'name|n' "The name"
)
:args "My function" "${@}"
echo "Hello ${name}"
}

How to Suppress

# argsh disable=AG005
my_func() {

Or file-wide:

# argsh disable-file=AG005
Was this section helpful?