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

Processing additional cli arguments #80

Closed
wants to merge 1 commit into from
Closed

Processing additional cli arguments #80

wants to merge 1 commit into from

Conversation

ilyapuchka
Copy link
Collaborator

@ilyapuchka ilyapuchka commented Dec 26, 2016

Resolves #14

@krzysztofzablocki
Copy link
Owner

What's the reason for the whitespace limitation?

@ilyapuchka
Copy link
Collaborator Author

ilyapuchka commented Dec 26, 2016

Commander that is used to parse command line attributes. It breaks them by spaces. There is though an alternative approach. At first I just pulled all remaining positional arguments in a dictionary. But that will require them to appear only in the end of the command and without --args, like this:

sourcery <paths> arg1=value arg2 arg3=value

Also just checked that with " there could be white spaces, so I need to add trimming

@krzysztofzablocki
Copy link
Owner

Ok thanks, I'll take a look today at tweaking this a little to use the same parsing code that we use for annotation line parsing so we have exactly same behaviour in both

@krzysztofzablocki
Copy link
Owner

moved to #82

@AliSoftware
Copy link
Contributor

I think @djbe added the ability to specify a flag multiple times in Stencil via a PR?
So you could do --args x 1 --args y 2?

@djbe
Copy link
Contributor

djbe commented Jan 5, 2017

No it was in Commander, and it was for repeating parameters like:
--import Something --import SomethingElse
Which resulted in a import array variable with as values ["Something", "SomethingElse"].

I think a better command line syntax would be:
--arg x=1 --arg y=2
Where you just parse the contents of the arg array.

@AliSoftware
Copy link
Contributor

Ah yeah of course I meant Commander ^^
Ok so this is definitely possible now 😉

@ilyapuchka
Copy link
Collaborator Author

Hm, didn't know about that option. @krzysztofzablocki should we use this feature instead of what we have implemented?

@djbe
Copy link
Contributor

djbe commented Jan 8, 2017

I'm planning on adding this functionality into StencilSwiftKit, so we can unify this for both codebases. Something that receives an array of strings such as:

[
  "foo.bar=test1",
  "foo.baz=test2",
  "AppModule=MyApp",
  "items=a",
  "items=b"
]

And converts it into a stencil context dictionary:

[
  "AppModule": "MyApp",
  "foo": [
    "bar": "test1",
    "baz": "test2",
  ],
  "items": [
    "a",
    "b"
  ]
]

To which you could then add whatever variables your parser provides.

@krzysztofzablocki
Copy link
Owner

I'm not entirely sure this isnt overkill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants