-
Notifications
You must be signed in to change notification settings - Fork 370
Rewrite of Program.Main, CLI args handling and config file reading #897 #944
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
Conversation
|
Please wait on doing any big merges until the Script LIbrary PR goes in. |
|
I rebased this after the script libraries changes went into dev (there were no conflicts) |
|
This is good to go now. |
|
rebased, FWIW |
|
@scriptcs/core it would be great if someone could have a look at this today. I'm flying to Portugal tomorrow afternoon and I'll be largely dark for a week. It's a big change set, but each commit is very focused so reviewing one commit at a time is probably going to be easiest and quickest. I'd love to see this go in. It's a massive simplification of the entry point to the app. |
|
does it handle stuf like |
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.
how is it possible it now shows up without new lines?
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've really no idea. It's a nice side effect of the PR though 😜
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.
Adam I meant in a function not a sep class :-)
On Sat, Mar 7, 2015 at 4:20 PM Adam Ralph notifications@github.com wrote:
In src/ScriptCs/Program.cs
#944 (comment):return 1; }
var scriptServicesBuilder = ScriptServicesBuilderFactory.Create(arguments.CommandArguments, arguments.ScriptArguments);var factory = new CommandFactory(scriptServicesBuilder);var command = factory.CreateCommand(arguments.CommandArguments, arguments.ScriptArguments);return (int)command.Execute();}if (commandArgs.Help){Console.WriteLine(ScriptCsArgs.GetUsage());I've really no idea. It's a nice side effect of the PR though [image:
😜]—
Reply to this email directly or view it on GitHub
https://github.com/scriptcs/scriptcs/pull/944/files#r26000964.
|
does it handle starting REPL with log level set? |
|
and a non-educated comment - you have deleted lots of tests; I understand the corresponding classes are gone, but do we no longer need to check the scenarios they covered? |
|
Guys, thanks very much for reviewing! It was nice to come home this evening to all these comments. In response:
Yes, that is handled inside
Yes, this has been handled in
There is way less code now and it is much simpler. The work now takes place in three places:-
I think all but one of the scenarios which these types affect are covered in the acceptance tests. The only one which isn't, is the masking of CLI args over local and global options files and, come to think of it, that acceptance test should probably be added. My general approach to testing is to ensure the important scenarios are covered by acceptance tests and only to drill down into 'unit tests' when it's felt some particular implementation detail is risky enough to require it. That's why I included a unit test for
Personally I would leave it where it is since it's trivial and single use. I only tend to encapsulate something if it's complicated or reused. If feelings are strong on this, I can encapsulate in a function. |
|
@glennblock sure, I meant function too, 'encapsulate' was the wrong word 😄 So to paraphrase what
Which part(s) do you think should move to a function? |
|
Lines 18 to 35, everything related to parsing the args
|
|
Parsing the args is already encapsulated in Tell you what, if this is the only thing you'd like to change, perhaps you can merge this PR and send your proposed refactoring in a new PR? |
|
@filipw I've added Configuration scenarios to the acceptance tests |
|
I am not finished reviewing. As to the refactoring it is reducing the code in Main and making it more readable. Extract Method is a very common pattern. The lines I mentioned can be easily ripped to a parse method. |
|
Sure, I'm familiar with Extract Method 😉. I guess it's a matter of taste. IMHO the lines should stay where they are. The key aspect is the return codes. There are a few cases in the method which There is actually only one line which does arg parsing, and that is line 22. The heavy lifting there is already extracted into The only lines which I think could be moved elsewhere are:
|
|
Ultimately |
|
hold until post 0.14 |
|
0.14 has been released, so this PR is good to go again. |
|
hold off - see #990 |
|
@glennblock |
|
This is good to go again. |
|
|
…e and fix whitespace
…L and file extension
Rewrite of Program.Main, CLI args handling and config file reading #897
|
👍 Great work, much more simplified! |

fixes #990
fixes #897
fixes #945
fixes #962
fixes #963