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

Commander doesn't... parse arguments? #11

Closed
Danappelxx opened this issue Oct 5, 2015 · 4 comments
Closed

Commander doesn't... parse arguments? #11

Danappelxx opened this issue Oct 5, 2015 · 4 comments

Comments

@Danappelxx
Copy link

With the following swift file called main:

#! /usr/bin/env cato 2.1
import Commander


Group {
    $0.command("init") { (name: String) in
        print("Initializing \(name)")
    }
}.run()

As expected, running:

$ chmod +x main
$ ./main

results in

Usage:

    $ ./main

Commands:

    + init

Which is great! However, when I run the following command, I get the same result:

$ ./main init test
Usage:

    $ ./main

Commands:

    + init

instead of the expected:

$ ./main init test
Creating test

Is this an error on my part or is it broken?

By the way, I'm on OS X El Capitan running Xcode 7.1 Beta 2, if it matters.

@kylef
Copy link
Owner

kylef commented Oct 5, 2015

Hi @Danappelxx,

I had a quick look into this, and it seems that there is a bug in Cato where it's not passing the arguments into the tool correctly. /cc @neonichu

Here is the expected output:

$ chmod +x bin/test
$ ./bin/test
Usage:

    $ ./bin/test

Commands:

    + init

$ ./bin/test init
Missing argument
$ ./bin/test init x
Initialising x

May I suggest you try using CocoaPods-Rome instead for now until this is figured out. Your script would look something like:

#!/usr/bin/env xcrun swift -F Rome

import Commander

Group {
  $0.command("init") { (name: String) in
    print("Initializing \(name)")
  }
}.run()

Where the told line references the Rome folder that contains your dependencies managed by Rome. You have a Podfile where you specify your tools dependencies:

platform :osx, '10.10'
use_frameworks!
plugin 'cocoapods-rome'

pod 'Commander'

Then you can simply run pod install while using Rome and then invoke your script.

I am working to simplify this process with a build tool and I'll add more about that once it's ready to use.

@neonichu
Copy link
Contributor

neonichu commented Oct 5, 2015

😱

@Danappelxx
Copy link
Author

Thanks! I'll look into it. By the way, have you discovered any workarounds that allow you to use Commander (or any framework, really) in Xcode cli projects? Putting it in /library/frameworks didn't do the trick for me for some reason. Cato would work by just moving it to /usr/local/bin, but clearly that's not an option for now :). Rome is an issue because it creates a directory in its current path, which would be slightly unfeasible in /usr/local/bin, or at the very least really messy.

@kylef
Copy link
Owner

kylef commented Oct 24, 2015

Closing this issue since it's not a problem in Commander but cato.

As for your question, I'm not entirely sure about Xcode projects. I use Xcode anymore, but instead Conche.

With Rome, that's fine, you just need to ensure the Frameworks when you install are in the applications path.

As you can see in querykit cli it will copy to Frameworks from Rome in installation and then add Frameworks to the rpath.

cp -fr "Rome/" "$(DESTDIR)/Frameworks/"
install_name_tool -add_rpath "@executable_path/../Frameworks/"  "$(DESTDIR)/bin/querykit"

@kylef kylef closed this as completed Oct 24, 2015
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

No branches or pull requests

3 participants