Skip to content

Commit a4c95ca

Browse files
author
Kevin Paulisse
committed
Create documentation for .config API
1 parent f868a7a commit a4c95ca

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

bin/octocatalog-diff

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ logger = Logger.new(STDERR)
2424
logger.level = Logger::DEBUG if config_test
2525

2626
options = OctocatalogDiff::API::V1.config(logger: logger, test: config_test)
27+
exit(0) if config_test
2728

2829
argv = ARGV.dup
2930
exit_code = OctocatalogDiff::Cli.cli(argv, Logger.new(STDERR), options)

doc/dev/api/v1/config.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,36 @@
22

33
## Overview
44

5-
`config` allows you read and parse an [octocatalog-diff configuration file](/doc/configuration.md).
5+
`config` reads and parses an [octocatalog-diff configuration file](/doc/configuration.md).
6+
7+
```
8+
options = OctocatalogDiff::API::V1.config(
9+
filename: "String",
10+
logger: Logger,
11+
test: <true|false>
12+
)
13+
```
14+
15+
#### Options
16+
17+
- **`:filename`** (String, optional): Full path to configuration file to read. If not provided, the configuration file will be searched as described in [Configuration](/doc/configuration.md).
18+
19+
- **`:logger`** (Logger, optional): Logger object. If provided, debug messages and fatal errors will be logged to this object.
20+
21+
- **`:test`** (Boolean, optional): Test mode, defaults to false. If true, the value of the configuration settings will be logged to the logger (with priority DEBUG) and an exception will be raised if the configuration file cannot be located.
22+
23+
#### Return value
24+
25+
If the configuration file is located and valid, the return value is a Hash consisting of the options defined in the configuration file.
26+
27+
If the configuration file cannot be found, the return value is an empty Hash (`{}`). Except, if you specified `:test => true`, an exception will be raised.
28+
29+
#### Exceptions
30+
31+
- `OctocatalogDiff::Errors::ConfigurationFileContentError`
32+
33+
Raised if the configuration file could not be parsed. A more specific error message will help identify the cause. Possible causes include the file not being valid ruby, the file not containing the expected structure or methods, or the method returning something other than a Hash.
34+
35+
- `OctocatalogDiff::Errors::ConfigurationFileNotFoundError`
36+
37+
Raised if the configuration file could not be found, *and* `:test => true` was supplied.

0 commit comments

Comments
 (0)