-
-
Notifications
You must be signed in to change notification settings - Fork 405
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: look harder for $PWD/cfg, don't automatically start config wizard #2093
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of behavior change isn't appropriate for our upcoming patch release series (7.1.x), so I'll have to tag it for 8.0. It will fit right in with some other CLI changes I remember Exi talking about wanting to do.
Just one idea in notes below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me.
sopel/cli/run.py
Outdated
"To start the configuration wizard, run `sopel configure`", | ||
sep="\n", | ||
) | ||
sys.exit(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will be a hard no for me: sys.exit
shouldn't appear here, and left to the caller to decide when to exit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem is the caller needs the exception re-raised to know that it should exit, and re-raising the exception will print the error text again in both places where this func is called—exactly the redundancy I asked mal to eliminate.
Lines 410 to 414 in a174d18
try: | |
settings = get_configuration(opts) | |
except config.ConfigurationError as e: | |
tools.stderr(e) | |
return ERR_CODE_NO_RESTART |
Lines 608 to 612 in a174d18
try: | |
settings = get_configuration(opts) | |
except config.ConfigurationError as e: | |
tools.stderr(e) | |
return ERR_CODE_NO_RESTART |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes? There is nothing that prevent that code to raise a new exception with a different error message, it looks like it'll work properly and do exactly what is expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts? Not redundant, no exit()
, doesn't rely on context in a way that rubs me weird but exi says is fine.
$ sopel -c foobar
Welcome to Sopel! To start the configuration wizard, run `sopel configure`
Unable to find the configuration file /home/user/.sopel/foobar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outputting the solution before stating the problem is a bit weird, but tolerable. There's no rule saying this can't be changed again later, after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't get why raising a fresh new exception is bad, but I guess it can be changed again later, after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See latest - Add ConfNotFound.hint
for preferred order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking the spelling and style. I'll let Exi come back and be Opinionated™ about the new exception approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I've take time to read the code from sopel/cli/run.py
and how get_configuration
is used: in both case, it catches the generic configuration error to print it and exit.
Now, why does get_configuration
exists? It does because it was a way to always get a configuration file and always run the wizard. Now, that's gone. Moreover, in #2118 I plan to simply remove the legacy mode.
So, I think adding the hint
property is not the right solution here, and it's making thing more complicated than they should be. There are 3 options:
- remove the try/except and put a comment in cli: remove legacy mode for run script #2118 to deal with a friendlier error message somehow
- raise a new configuration error (a generic one) with the proper message (I think I already suggested that)
- remove the try/except and catch the
ConfigurationNotFound
in command start (and forget about legacy, which is going down) to print a nice message (and also comment in cli: remove legacy mode for run script #2118 to say good luck with the merge conflict)
In any case, I don't see the point of adding a hint
attribute.
I recommend taking another look at the behavior on |
Ping @half-duplex for reevaluation of |
Removing from release plans due to lack of attention over a period of months. Can be reopened if a second wind hits, as always. |
Description
This fixes two annoyances:
.cfg
when searching the config dir, but it doesn't when searching the current working directoryCombining these two, a user (me) will (does, regularly)
cd
to their non-default Sopel config dir, runsopel -c mybot
expecting it to load mybot.cfg and run, but instead have Sopel create ~/.sopel/ and ~/.sopel/mybot.cfg and start the config wizard.Searching
$PWD/{config}.{ext}
is straightforward, but not automatically running the wizard is probably subject to opinions. I changed it to the below output, but I would also be content with "Do you want to run the configuration wizard? y/n", or at least not creating the folder/file until the end of the wizard so the user has an opportunity to ^C without having to thenrm -rf ~/.sopel
Amended "couldn't find config":
Checklist
make qa
(runsmake quality
andmake test
)