-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from nlnwa/config-files
Avoid naming conflicts for environment variables
- Loading branch information
Showing
15 changed files
with
233 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,23 @@ | ||
--- | ||
title: Usage | ||
weight: 2 | ||
weight: 20 | ||
--- | ||
|
||
The command line tool is named `warc`. The different functions are executed trough sub-commands. | ||
The Warchaeology tool is named `warc`. | ||
|
||
## Syntax | ||
``` | ||
warc [command [subcommand]] [flags] | ||
``` | ||
Where: | ||
* **command** and eventually **subcommand** specifies the operation that you want to perform. | ||
* **flags** specifies optional flags. For example, you can use the `--config` flag to specify | ||
the location of a configuration file. | ||
|
||
|
||
|
||
## Commands | ||
The following pages are generated from the built in documentation and can also be viewed on the | ||
command line with `warc <command> -h` | ||
|
||
{{< childpages >}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
title: Configuration | ||
weight: 30 | ||
--- | ||
|
||
## Configuration parameters | ||
|
||
Warchaeology commands can be configured by specifying parameters. | ||
There are several options for specifying parameters where using command line flags | ||
is the easiest. But if you find yourself always setting a specific flag it might be better | ||
to add a configuration file or environment variable. | ||
|
||
Flags set on the command line takes precedence over configuration files and environment variables. | ||
|
||
Parameter documentation can be found in the *options* section for each [command](/cmd). | ||
The parameter name is the long flag name with the dashes removed. | ||
|
||
## Environment variables | ||
|
||
Environment variables can be used to set parameters. Use the following steps to convert | ||
a parameter name to an environment variable name: | ||
* converting the parameter name to upper case | ||
* replace '-' with '_' | ||
* prefix with `WARC_` | ||
|
||
> Setting the environment variable **WARC_RECORD_COUNT=2** is equal to specify the flag `--record-count=2`. | ||
Environment variables takes precedence over parameters in config files. | ||
|
||
## Configuration File | ||
|
||
Parameters can also be set in configuration files. The configuration file format is YAML. | ||
|
||
#### File structure | ||
|
||
To set a configuration parameter use the parameter name as key and then the value: | ||
|
||
```yaml | ||
delimiter: "\t" | ||
record-count: 2 | ||
``` | ||
If you want to have a global default, but override the parameter for a specific command | ||
you can do so by adding a section with the command as key. | ||
```yaml | ||
delimiter: "\t" | ||
record-count: 2 | ||
ls: | ||
record-count: 5 | ||
convert: | ||
tmpdir: mydir | ||
arc: | ||
tmpdir: anotherdir | ||
``` | ||
This config file gives the following values | ||
{{< table style="table-striped" >}} | ||
| Command | parameter name | parameter value | | ||
|-------------------|----------------|-----------------| | ||
| warc cat | record-count | 2 | | ||
| warc ls | record-count | 5 | | ||
| warc ls | tmpdir | /tmp (default) | | ||
| warc convert warc | tmpdir | mydir | | ||
| warc convert arc | tmpdir | anotherdir | | ||
{{< /table >}} | ||
#### Config file location | ||
The standard configuration files are named `config.yaml` and are searched for in | ||
system default directories. | ||
|
||
The directories are looked up in the following order: | ||
|
||
1. Standard Global Configuration Paths | ||
* _Linux_: $XDG_CONFIG_DIRS or "/etc/xdg/warc" | ||
* _Windows_: %PROGRAMDATA% or "C:\\ProgramData/warc" | ||
* _macOS_: /Library/Application Support/warc | ||
|
||
2. Standard User-Specific Configuration Paths | ||
* _Linux_: $XDG_CONFIG_HOME or "$HOME/.config/warc" | ||
* _Windows_: %APPDATA% or "C:\\Users\\%USER%\\AppData\\Roaming\\warc" | ||
* _macOS_: $HOME/Library/Application Support/warc | ||
|
||
3. Working directory | ||
* The directory warc was started from | ||
|
||
All steps are searched for a file named `config.yaml` and if found, | ||
values in a later file will override values in the files before it. | ||
|
||
By setting the command line flag `--config` to a file name, the user can override the default | ||
config with a user specified config file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: Contributing | ||
weight: 3 | ||
weight: 50 | ||
--- | ||
|
||
## Getting Started | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.