-
Notifications
You must be signed in to change notification settings - Fork 124
Comment overhaul #631
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
Comment overhaul #631
Conversation
Codecov Report
@@ Coverage Diff @@
## master #631 +/- ##
==========================================
- Coverage 94.08% 94.07% -0.01%
==========================================
Files 10 10
Lines 2957 2954 -3
==========================================
- Hits 2782 2779 -3
Misses 175 175
Continue to review full report at Codecov.
|
tleonhardt
left a comment
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.
Overall it looks good, but please look at my comments.
| ``AutoCompleter`` which has since developed a dependency on ``cmd2`` methods. | ||
| * Removed ability to call commands in ``pyscript`` as if they were functions (e.g ``app.help()``) in favor | ||
| of only supporting one ``pyscript`` interface. This simplifies future maintenance. | ||
| * No longer supporting C-style comments. Hash (#) is the only valid comment marker. |
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.
@kotfu I'd like to make sure we get your input on these two potentially breaking changes. I think they are good chances in terms of simplifying things and making the code more maintainable. But I want to make sure this doesn't negatively impact anything you are working on.
|
Nothing I am working on requires either C-style comments or embedded comments. So from that perspective, I'm totally OK with removing this. The only reason I added support for C-style comments when we rewrote the parser is because we had previously supported them. The Breaking backwards compatibility with previous releases of Our own So what if we made the supported commenting styles some sort of setting? I'm even OK with the default being only supporting I like the configurable comments because some use cases, like the one @kmvanbrunt outlined, are complicated or impossible if you use python/shell style commenting (either at the beginning of the line or in the middle of the line). In other cases, the C-style comments conflict with the desired input syntax. Configurable comments allows our implementers to choose whether they want no comments, python/shell style comments, C-style comments, or all the comments. What do you think? If we decide to do configurable comments, I'm happy to take on the changes to StatementParser. |
|
@kotfu Maybe I'm misunderstanding |
|
Because the description is preceded with a ‘#’, making it look like an embedded or inline comment.
…On Mar 2, 2019, 1:16 PM -0700, kmvanbrunt ***@***.***>, wrote:
@kotfu Maybe I'm misunderstanding set -l. I thought it just listed the setting with a description. Why do you say it implies the support of embedded comments?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@kotfu But that's just the description from the However, if you think it could confuse a user, we can always change the character that precedes the description. |
|
I'd like to steer away from configuration settings that nobody is likely to use. My opinion is that we should just remove support for C-style comments - to me they always felt out of place in a Python framework and I'm not aware of anyone ever having used them. And any of these breaking changes I want to do a release or two before the 1.0.0 release that we are gearing up towards. I have mixed feelings about embedded Python comments. I see the advantage in terms of simplicity and ease of maintenance of not making it configurable and only allowing full-line comments. But I also see the advantage of making it configurable to either allow in-line comments or not - that would allow the option of backward compatibility and may be useful for some people; though I am also not aware of anyone actually using embedded comments. If we made it configurable, what would the default be? What are your thoughts? |
|
@tleonhardt I understand the desire to not break existing scripts. I just don't think the risk is very high that we will do so by removing embedded comment support. If we allow the behavior to be configurable, The approach this PR implements will allow all commands to work without having to toggle a flag. Since the # has to begin the line, it sits in the token reserved for the command name. Therefore it can never conflict with any command set our users think up because commands cannot contain a # character. |
|
One more thing. Allowing embedded comments automatically breaks our |
|
@kmvanbrunt You make an important point about supporting embedded comments breaking the @kotfu Would you be ok with keeping it simple and not making it configurable, or do you feel strongly that there is benefit in making it configurable? |
|
I'm supportive of dropping C-style comments. The only reason I feel super strongly about having configurable comments is to retain backwards compatibility. If we decide we don't care, then there is no reason to have configurable comments. I disagree with the notion that these changes make the code more maintainable. We are removing two lines of well-tested, well-encapsulated, and well-documented code. I disagree that allowing embedded comments "breaks our shell command". Our current approach to comments using the hash symbol (i.e. excluding C-style comments) follows exactly the commenting syntax of I also understand that I'm in the minority in my position, and yield to the decision of the group. |
|
Hmm .. perhaps I am making much ado about nothing. If it is really a matter of a couple/few lines of well-tested, well-encapsulated, well-documented code; then that isn't a maintenance headache. @kotfu You make a good point about how in general we attempt to support syntax similar to @kmvanbrunt How about we try adding back in the code to support embedded Python comments based on a configuration called something like |
|
If embedded comments were allowed based on a flag, I would want the default to be to not allow them in order to have maximum support of shell command usage on Windows. |
|
@kotfu @tleonhardt Because of how we do This is from Python's documentation:
So if I try: @kotfu is correct that the Unix shells In those shells, most would assume this line ends in a comment: While that may seem like an obscure case, I don't think it's inconceivable for a user to have a folder named something similar to What the example demonstrates is that we aren't totally following Our help text for shell is "Execute a command as if at the OS prompt". I believe this PR best accomplishes that objective since the underlying shell does not require users to quote I hope this clarifies my earlier statement where I said: "Allowing embedded comments automatically breaks our shell command". I also just discovered that embedded comments break tab completion of paths. Since a folder called I certainly am not fond of breaking anyone's existing scripts. If that happens, I will take the blame. Honestly though, I'm betting we won't see any complaints and if we do, it is a trivial thing for them to move a comment to the line preceding the command. Also, if the user understood the limitations embedded comments add to other functionality of cmd2, I think they would be fine forgoing the feature. |
|
Wow. The more I learn about shells, the more I am surprised to learn that there is still a lot I don’t know! cmd2 does a very admirable job of providing an excellent shell-like application environment on both POSIX and Windows OSes, which isn’t easy. I don’t like breaking backwards compatibility, but it seems like there are good reasons in this case. Let’s do our best to get to a very stable base for the 1.0 release where we have extremely few breaking changes after that. |
|
Well, this one has had some healthy debate ;-) I'm not 100% sure we are making the right choice, but I'm going to merge and and move forward. If we find any gotchas, we can add back in embedded comments. |
Removed support for C-style and embedded comments
This reason I simplified our comment support is because of problems running certain commands at the shell.
On windows, this won't work:
!rundll32 bob.dll,#5Since # is our comment character, the last part of that command is removed. I also can't quote the string because we preserve quotes on commands being passed to other shells and I agree with that approach. In this case
rundll32.exedoesn't seem to like the quotes around the string.Since cmd2 is primarily a shell application, I think embedded comment support is unnecessary. Comments really only are applicable in text scripts, and it's reasonable to have users type comments on their own lines.
Also, C-style comments don't offer any advantage in a text script. I'm OK just letting these go since adding code to prevent them from being embedded will just be more code we have to maintain for a feature I'm not sure if anyone uses.