• No results found

Flags and Arguments

In document PGP Command Line User's Guide (Page 49-52)

PGP Command Line uses flags, commands, options, and arguments:

ƒ Flags come in two different types, commands and options. Commands are flags that control what PGP Command Line does in its current invocation; they have no effect on subsequent invocations of PGP Command Line. Options change the behavior of the current command.

Some options require an argument, described below, while others do not.

The order in which flags are listed on the command line has no effect on their behavior.

ƒ Arguments are required as the next parameter when an option flag is used. Arguments must immediately follow their flags. Where the flag/argument pair are on the command line does not change what the flag/argument pair does. Except when setting lists, in which case the command is read left to right; so when searching keyservers, for example, the listed keyservers are searched in the order in which they are provided on the command line.

Flags and arguments must be separated by a space on the command line. Extra spaces are ignored. If a space between parts of an argument is required, the entire argument must be between quotes.

In some cases, there can be multiple names for a single flag.

For example:

--textmode and --text (same flag with two names)

It is also possible to provide an option that has no effect on the current operation. Flags that have no bearing on the current operation are ignored, unless they cause an error, in which case the command returns an error.

For example:

--list-keys Alice with the option --encrypt-to-self (the option --encrypt-to-self will be ignored)

Flags

As noted above, flags have both long and short forms. To combine multiple long forms, you simply write them out separated by a space. For example, to encrypt a file and armor the output:

pgp --encrypt ... --armor

You can, however, combine multiple short forms into a single flag. For example, to encrypt and sign at the same time:

pgp -es ...

36

When combining short forms, if at any time an option is used in the list that requires an argument, the list must be terminated and followed by the argument. For example: -ear recipient.

Arguments

An argument is required as the next parameter when some option flags are used. There are several kinds of arguments, differentiated by how they are structured or what kind of information is provided.

The kinds of arguments are:

ƒ Booleans

ƒ Integers

ƒ Enumerations

ƒ Strings

ƒ Lists

ƒ File descriptor

ƒ No parent

Booleans

Booleans are a special kind of argument. They never take a direct argument themselves. Instead, the behavior changes by how the flag is specified. To disable a Boolean, specify it with the prefix "--no-" instead of the normal "--".

When the short form is used for a Boolean flag, there is no way to specify the disabled version of the flag.

For example:

--reverse-sort (activates reverse sorting)

--no-compress (deactivates compression, the reverse of --compress) -t (activates text mode; to deactivate text mode, the long form must be used, --no-text)

Integers

Integers are arguments that take a numeric value.

For example:

--wipe-passes 8 (sets the number of wipe passes to eight)

37

Enumerations

Enumerations are arguments that take a string, which is then converted to the correct value by PGP Command Line. This string will be one of several possible for each flag.

For example:

--sort-order userid (sort by user ID)

--overwrite remove (sets the file overwrite behavior to remove files if they exist)

Strings

String arguments take a string. If the string you want to use contains any spaces, the entire string must be in quotes (this indicates that all of the pieces belong to the same argument). In some cases, an empty string (" ") can be passed as an argument.

On Windows systems, strings are read in as double-byte character strings and converted to UTF-8 for use by the PGP SDK or for output. On all other platforms, UTF-8 is used.

For example:

--default-key 0x8885BE88 (sets the key with this key ID as the default key)

--output "New File.txt.pgp" (sets the output filename to a filename with a space in it)

--passphrase "" (specifies a blank passphrase)

--expiration-date 2008-12-27 (specifies an expiration date of Dec.

27, 2008)

Lists

List arguments are the same as string arguments except you can supply more than one string.

For example:

--recipient bob --recipient bill (sets both Bob and Bill as recipients)

-r bob -r bill (same command using the short form of the flag)

38

File descriptors

File descriptor arguments behave like integer arguments, but instead of storing the value of the descriptor, PGP Command Line reads a string value from the descriptor. These string values always have a string type counterpart.

If you need to specify the data in UTF-8 format on a Windows system, use the

"8" versions of the file descriptor options.

For example:

--passphrase-fd 4 (read passphrase from fd 4 and use it as if --passphrase had been supplied)

--passphrase-fd8 7 (read a UTF-8 passphrase from fd 7)

No parent

Arguments that have no parent flag behave like lists and follow the same rules.

They are used in different ways, depending on the operation being performed, but they can occur anywhere in the command line except after a flag that has a required argument.

These arguments can represent users or represent files.

For example

--list-keys Alice Bob Bill (list all keys that match any one of these users)

--encrypt file1.txt file2.txt file3.txt (encrypt multiple files with the same command)

In document PGP Command Line User's Guide (Page 49-52)