[−][src]Function dia_args::parse_file
pub fn parse_file<P>(
file: Option<P>,
permissions: Option<Permissions>,
max_size: Option<u64>
) -> Result<Option<Args>> where
P: AsRef<Path>,
Parses from file
Rules
Default file
- Default file is a file named
DIA_ARGS_FILE_NAME
within directory of the program. On Unix, if the program is a symlink, its parent directory is used. The parent directory of the original file is not used.[1]
- If
None
is given, default file will be used. - If the file does not exist,
None
is returned.
Limits and syntax
-
If
max_size
is zero, an error is returned. IfNone
,MAX_DIA_ARGS_FILE_SIZE
will be used. If the file's size is larger than provided value, an error is returned. -
On Unix:
- If you don't provide permissions, the file's permissions must be equal to or more restrictive than the program's owners'. Or an error will be returned.
- If you provide permissions, the file's permissions must match them exactly, or an error will be returned.
-
Empty lines or lines starting with
#
will be ignored. -
Each command, argument, or option must be placed on a separate line.
-
Normally, a shell will remove leading/trailing marks such as
"..."
or'...'
. However those are not required in this file. So you can separate options like these:--passphrase=secret passphrase with white-spaces in it --passphrase = secret passphrase with white-spaces in it --passphrase secret passphrase with white-spaces in it
They're all the same. Also, note that values will be trimmed.
^^
In theory, that is the goal. Howeverenv::current_exe()
function might return the original file (not the symlink). In that case, the parent directory of the original file will be used.