mirror of
https://github.com/nicolabs/nicobot.git
synced 2025-09-06 03:04:48 +02:00
~ --config-dir becomes --config-dirs for clarity
This commit is contained in:
parent
10a385bbec
commit
b4a2c78c7b
|
@ -310,7 +310,7 @@ matched = [ p['name'] for p in output['messages'][-1]['patterns'] if p['matched'
|
|||
|
||||
The following options are common to both bots :
|
||||
|
||||
- **--config-file** and **--config-dir** let you change the default configuration directory and file. All configuration files will be looked up from this directory ; `--config-file` allows overriding the location of `config.yml`.
|
||||
- **--config-file** and **--config-dirs** let you change the default configuration directory and file. All configuration files will be looked up from this directory ; `--config-file` allows overriding the location of `config.yml`.
|
||||
- **--backend** selects the *chatter* system to use : it currently supports "console", "signal" and "jabber" (see below)
|
||||
- **--stealth** will make the bot connect and listen to messages but print answers to the console instead of sending it ; useful to observe the bot's behavior in a real chatroom...
|
||||
- **--debug / -d / --verbosity / -v** those options modify the verbosity level : `--debug` is a flag that sets it to *DEBUG* while with `--verbosity` you can define [the exact level](https://docs.python.org/3/library/logging.html#levels) (e.g. `-v TRACE`).
|
||||
|
@ -320,7 +320,7 @@ The following options are common to both bots :
|
|||
#### Configuration file : config.yml
|
||||
|
||||
Options can also be taken from a configuration file.
|
||||
By default it reads the `config.yml` file in the current directory but can be changed with the `--config-file` and `--config-dir` options.
|
||||
By default it reads the `config.yml` file in the current directory but can be changed with the `--config-file` and `--config-dirs` options.
|
||||
|
||||
This file is in YAML format with all options at root level.
|
||||
Keys are named after the command line options, with middle dashes `-` replaced with underscores `_` and a `s` appended for lists (option `--ibmcloud-url https://api...` will become `ibmcloud_url: https://api...` and `--keywords-file 1.json --keywords-file 2.json` will become :
|
||||
|
|
|
@ -72,7 +72,7 @@ case "${opt_bot}" in
|
|||
askbot|transbot)
|
||||
#exec python3 -m "nicobot.${opt_bot}" "$@"
|
||||
# TODO Allow to override config dirs with the docker command line
|
||||
exec "${opt_bot}" "--config-dir" /etc/nicobot /var/nicobot "$@"
|
||||
exec "${opt_bot}" "--config-dirs" /etc/nicobot /var/nicobot "$@"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown bot : '*{opt_bot}'" >2
|
||||
|
|
|
@ -90,7 +90,7 @@ class ArgsHelper:
|
|||
|
||||
# Bootstrap options
|
||||
parser.add_argument("--config-file", "-c", "--config", dest="config_file", default=self.config_file, help="YAML configuration file.")
|
||||
parser.add_argument("--config-dir", "-C", dest="config_dirs", nargs='+', default=self.config_dirs, help="Directories where to find configuration files by default.")
|
||||
parser.add_argument("--config-dirs", "-C", dest="config_dirs", nargs='+', default=self.config_dirs, help="Directories where to find configuration files by default.")
|
||||
parser.add_argument('--verbosity', '-v', dest='verbosity', default=self.verbosity, help="Log level")
|
||||
# Chatter-generic arguments
|
||||
parser.add_argument("--backend", "-b", dest="backend", choices=['console','jabber','signal'], default=self.backend, help="Chat backend to use")
|
||||
|
|
|
@ -28,25 +28,25 @@ class TestOptions(unittest.TestCase):
|
|||
config = AskbotConfig()
|
||||
args = []
|
||||
config = parse_args_2pass( self.parser, args, config )
|
||||
self.assertTrue( len(config.config_dirs) == 1 )
|
||||
self.assertEqual( 1, len(config.config_dirs) )
|
||||
self.assertEqual( os.path.realpath(os.getcwd()), os.path.realpath(config.config_dirs[0]) )
|
||||
|
||||
def test_config_path_custom(self):
|
||||
|
||||
# Using AskbotConfig but it could be another one as long as this test is not askbot-specific
|
||||
config = AskbotConfig()
|
||||
args = [ '--config-dir', '/tmp/nicobot' ]
|
||||
args = [ '--config-dirs', '/tmp/nicobot' ]
|
||||
config = parse_args_2pass( self.parser, args, config )
|
||||
self.assertTrue( len(config.config_dirs) == 1 )
|
||||
self.assertEqual( 1, len(config.config_dirs) )
|
||||
self.assertEqual( os.path.realpath('/tmp/nicobot'), os.path.realpath(config.config_dirs[0]) )
|
||||
|
||||
def test_config_path_default_and_custom(self):
|
||||
|
||||
# Using AskbotConfig but it could be another one as long as this test is not askbot-specific
|
||||
config = AskbotConfig()
|
||||
args = [ '--config-dir', '/etc/nicobot', '/tmp/nicobot' ]
|
||||
args = [ '--config-dirs', '/etc/nicobot', '/tmp/nicobot' ]
|
||||
config = parse_args_2pass( self.parser, args, config )
|
||||
self.assertTrue( len(config.config_dirs) == 2 )
|
||||
self.assertEqual( 2, len(config.config_dirs) )
|
||||
self.assertEqual( os.path.realpath('/etc/nicobot'), os.path.realpath(config.config_dirs[0]) )
|
||||
self.assertEqual( os.path.realpath('/tmp/nicobot'), os.path.realpath(config.config_dirs[1]) )
|
||||
|
||||
|
|
Loading…
Reference in a new issue