-
Notifications
You must be signed in to change notification settings - Fork 3
Home
This information is current as of 5.0.0
While making Another Archery Tweak I noticed the lack of any utilities to convert between real-life units & the game engine's "Units", and decided to do something about it.
After a lot of searching due to Bethesda's questionable choice of calling their length measurement units "Units", I stumbled upon this helpful table on the creation kit wiki.
To understand what is and isn't allowed on the commandline, you need to know how the program handles arguments.
Most of this information is transferable to any other CLI program, with some exceptions, such as terminology.
-
Strings of characters that appear after the executable name and are passed directly to the program.
They are separated with spaces, and either single or double quotation marks can be used to pass multiple words as one argument.
An argument may have one of 3 types, denoted by the number of prefix dashes. -
Any Argument that does not have any dashes as a prefix.
-
This is a type of Argument that has a special meaning to the program, and is usually used to specify optional features or modes.
Certain specific options may capture additional input in the form of the following Parameter, or by appending an equals sign.
Example:ckconv --precision=8
, andckconv --precision 8
mean the same thing.
Note: Appending input with=…
does not work if the input contains a space, use="…"
instead. -
These are multiple-character Options that use 2 dashes as a prefix.
Example:ckconv --no-color
-
These are single-character Options that use 1 dash as a prefix, and are usually used as an alias for a long-form option.
Flags are unique in that they can be chained together using a single dash.
Only the flag at the end of the chain may capture additional input.
Example:ckconv -nq
is the same asckconv --no-color --quiet
Note: The argument parser is smart enough to differentiate between negative numbers and flags.
- Argument Parsing
- Config Parsing & Handling
- Option Handling
- Unit Conversion from Parameters
- Unit Conversion from STDIN
Arguments are parsed in-order before they are used in the program.
The steps below are repeated for each argument.
- Check the number of prefixed dashes
-
& assign the argument a type. - If an equals sign appears in the argument, move the characters that appear after it (Excluding quotation marks) into the next argument's "position" in the list.
Note: This is just a layman's explanation of how captures are handled, the input array is not actually reordered. - Check if the argument appears on the hardcoded "capture whitelist"; If it does, capture the next argument in the list if any of the following are true:
- The next argument was appended to this option with an
=
sign. - The next argument is a Parameter
Next, the program checks if the INI config was found. The INI must have the same filename as the executable, with a .ini
extension, and must be located in the same directory as the executable.
Example: ckconv.exe
looks for ckconv.ini
in the same directory.
Next, the argument list is checked for the following options:
-
-h
|--help
-
-v
|--version
If one of the above options is detected, either the inline help display and/or the current version number will be displayed, then the program will exit. Otherwise, the program checks for other recognized options, such as--standard
,--precision
, etc.
The order in which these options are handled is not listed here, as it may change between versions.
Finally, the program checks for the--reset-ini
(or--ini-reset
) option, and if found, the current settings are written to the INI config file.
Exactly 3 arguments are required for each conversion operation, which allows multiple operations to be processed using context.
Each operation requires an input number & unit, and a target unit to convert to. Arguments can appear in one of 2 orders:
-
<INPUT_UNIT>
<INPUT_VALUE>
<OUTPUT_UNIT>
-
<INPUT_VALUE>
<INPUT_UNIT>
<OUTPUT_UNIT>
This only occurs when there is piped input available in the STDIN stream, and the syntax is identical to Step 4, newlines are ignored.
This includes using the vertical bar operator |
with something like cat
.
Example: cat myFile | ckconv