Understanding positional parameters

You can take advantage of the positional parameter functionality of the ONTAP CLI to increase efficiency in command input. You can query a command to identify parameters that are positional for the command.

What a positional parameter is

Attention: Using the positional parameter functionality in scripts is not recommended, especially when the positional parameters are optional for the command or have optional parameters listed before them.

How to identify a positional parameter

You can identify a positional parameter in the command_name ? command output. A positional parameter has square brackets surrounding its parameter name, in one of the following formats:

For example, when displayed as the following in the command_name ? output, the parameter is positional for the command it appears in:

However, when displayed as the following, the parameter is nonpositional for the command it appears in:

Examples of using positional parameters

In the following example, the volume create ? output shows that three parameters are positional for the command: -volume, -aggregate, and -size.

cluster1::> volume create ?
   -vserver <vserver name>                             Vserver Name
   [-volume] <volume name>                             Volume Name
   [-aggregate] <aggregate name>                       Aggregate Name
  [[-size] {<integer>[KB|MB|GB|TB|PB]}]                Volume Size
  [ -state {online|restricted|offline|force-online|force-offline|mixed} ]  
                                                       Volume State (default: online)
  [ -type {RW|DP|DC} ]                                 Volume Type (default: RW)
  [ -policy <text> ]                                   Export Policy
  [ -user <user name> ]                                User ID
  [ -space-guarantee|-s {none|volume} ]                Space Guarantee Style (default: volume)
  [ -percent-snapshot-space <percent> ]                Space Reserved for Snapshot Copies

In the following example, the volume create command is specified without taking advantage of the positional parameter functionality:

cluster1::> volume create -vserver svm1 -volume vol1 -aggregate aggr1 -size 1g 
-percent-snapshot-space 0

The following examples use the positional parameter functionality to increase the efficiency of the command input. The positional parameters are interspersed with nonpositional parameters in the volume create command, and the positional parameter values are specified without the parameter names. The positional parameters are specified in the same sequence indicated by the volume create ? output. That is, the value for -volume is specified before that of -aggregate, which is in turn specified before that of -size.

cluster1::> volume create vol2 aggr1 1g -vserver svm1 -percent-snapshot-space 0

cluster1::> volume create -vserver svm1 vol3 -snapshot-policy default aggr1 -nvfail off 1g 
-space-guarantee none