Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: add sopel-config {list,init,get} #1507

Merged
merged 1 commit into from
Mar 27, 2019
Merged

Conversation

Exirel
Copy link
Contributor

@Exirel Exirel commented Mar 19, 2019

Replace #1465

The sopel-config is a CLI tool to:

  • list existing configuration file from Sopel's homedir
  • init a new configuration file in Sopel's homedir
  • get a value from a section.option of Sopel's configuration

It could do much more, but I'll leave it here for now, since @dgw is quite busy.

Note: sopel-config list could replace sopel --list, and sopel-config init could replace sopel --wizard in the end. That requires more thought.

@dgw
Copy link
Member

dgw commented Mar 20, 2019

I haven't gone very far into this, but I did find it odd that there's no argument to list configs from a non-default homedir. Have you just not built that yet or did you specifically leave it out for some reason?

@Exirel
Copy link
Contributor Author

Exirel commented Mar 20, 2019

I left it out because IIRC sopel start does not allow to use a different homedir: all you can do is to provide a configuration file. At the moment, Sopel is pretty strict about where its configuration file should be, and it lets you use another configuration file if you provide an absolute path or if you provide a relative path to the current directory. This can be seen by using the configuration wizard.

I don't really like it, but the bot isn't very good at managing that at the moment. Even though I think it's a very valid concern to have.

@Exirel Exirel force-pushed the sopel-cli-config branch from ab4e01b to 27017ce Compare March 20, 2019 10:29
@dgw
Copy link
Member

dgw commented Mar 20, 2019

I smell a future enhancement, then. For this PR I'll ignore that omission, since it's out of scope to do anything about it here.

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the code looks all kinds of sensible.

I'll load it up and test the CLI a bit Soon™, but until then I left the usual crop of line notes nitpicking docstrings. 😉

sopel/cli/config.py Outdated Show resolved Hide resolved
sopel/cli/config.py Outdated Show resolved Hide resolved
sopel/cli/config.py Outdated Show resolved Hide resolved
sopel/cli/config.py Outdated Show resolved Hide resolved
sopel/cli/config.py Outdated Show resolved Hide resolved
sopel/cli/config.py Outdated Show resolved Hide resolved
sopel/cli/config.py Outdated Show resolved Hide resolved
sopel/cli/config.py Outdated Show resolved Hide resolved
sopel/cli/config.py Outdated Show resolved Hide resolved
sopel/cli/config.py Outdated Show resolved Hide resolved
@Exirel
Copy link
Contributor Author

Exirel commented Mar 20, 2019

Push changes without rebase, since everything will be squashed into one commit in the end.

@dgw
Copy link
Member

dgw commented Mar 20, 2019

That makes it easy to see what you did, so :D

I was playing with the documentation and I tried making this change:

diff --git a/sopel/cli/config.py b/sopel/cli/config.py
index c8a2d29e..13462539 100644
--- a/sopel/cli/config.py
+++ b/sopel/cli/config.py
@@ -62,8 +62,7 @@ def build_parser():
 def handle_list(options):
     """Display a list of configuration available from Sopel's homedir
 
-    :param options: parsed arguments
-    :type options: ``argparse.Namespace``
+    :param argparse.Namespace options: parsed arguments
 
     This command displays an unordered list of config names from Sopel's
     default homedir, without their extensions::
@@ -92,8 +91,7 @@ def handle_list(options):
 def handle_init(options):
     """Use config wizard to initialize a new configuration file for the bot
 
-    :param options: parsed arguments
-    :type options: ``argparse.Namespace``
+    :param argparse.Namespace options: parsed arguments
 
     .. note::
 

Doing it that way makes Sphinx auto-link to the Python documentation for argparse.Namespace, which is nice. It also makes use of the fact that :param: takes a type inline, and eliminates excess lines.

It's not useful right now (because Sphinx isn't documenting anything in sopel.cli—that needs fixing too, in a separate PR), but in playing with the output I like this better.

(sopel.cli.run also outputs a not-so-nice docstring header because it still has that copyright bit in it, and Sphinx autodoc pulls the whole thing in… Again, separate PR for actually putting the whole cli submodule into the docs.)

@dgw dgw removed the Needs Review label Mar 20, 2019
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, because my last comment isn't really that important.

The `sopel-config` is a CLI tool to:

* list existing configuration file from Sopel's homedir
* init a new configuration file in Sopel's homedir
* get a value from a section.option of Sopel's configuration
@Exirel Exirel force-pushed the sopel-cli-config branch from 5101846 to 2ad7100 Compare March 25, 2019 15:46
@Exirel
Copy link
Contributor Author

Exirel commented Mar 25, 2019

@dgw rebased, squashed, Travis's happy, everything's good now!

@dgw
Copy link
Member

dgw commented Mar 27, 2019

Today's the day, @Exirel: You can start working on the next phase of this CLI. 😁

@dgw dgw merged commit d5187a0 into sopel-irc:master Mar 27, 2019
@Exirel Exirel deleted the sopel-cli-config branch September 5, 2019 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants