-
Notifications
You must be signed in to change notification settings - Fork 28
replace mruby-getopts with mruby-docopt #32
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
Open
toch
wants to merge
7
commits into
master
Choose a base branch
from
docopt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e846802
make test error messages more specific
hone db91625
WIP for moving over to mruby-docopt
hone 74759a7
Fix linking/compiling issues with mruby-docopt for linux and osx
toch a00f779
Enable win targets
toch a01354f
Allow to upgrade cmake to >3.1 for mruby-docopt
toch a0646c2
Replace mruby-getopts with mruby-docopt
toch 15e1f6d
link statically libstdc++ to avoid conflict with target libstdc++
toch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
FROM hone/mruby-cli | ||
FROM hone/mruby-cli:15.04 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends software-properties-common && \ | ||
add-apt-repository ppa:george-edison55/cmake-3.x && \ | ||
apt-get update && \ | ||
apt-get upgrade -y cmake | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,42 @@ | ||
module MRubyCLI | ||
class CLI | ||
def initialize(argv, output_io = $stdout, error_io = $stderr) | ||
@options = setup_options | ||
@opts = @options.parse(argv) | ||
@usage = setup_options | ||
@options = Docopt.parse(@usage, argv) | ||
@output_io = output_io | ||
@error_io = error_io | ||
end | ||
|
||
def run | ||
if app_name = @options.option(:setup) | ||
Setup.new(app_name, @output_io).run | ||
elsif @options.option(:version) | ||
if @options["setup"] | ||
Setup.new(@options["<name>"], @output_io).run | ||
elsif @options["--version"] | ||
Version.new(@output_io).run | ||
else | ||
Help.new(@output_io).run | ||
Help.new(@usage, @output_io).run | ||
end | ||
end | ||
|
||
private | ||
def setup_options | ||
options = Options.new | ||
options.add(Option.new("setup", "s", true)) | ||
options.add(Option.new("version", "v")) | ||
options.add(Option.new("help", "h")) | ||
USAGE = <<USAGE | ||
mruby-cli. | ||
|
||
options | ||
Usage: | ||
mruby-cli setup <name> | ||
mruby-cli (-v | --version) | ||
mruby-cli (-h | --help) | ||
|
||
Create your own cli application. | ||
Setup will scafold your application. | ||
|
||
Arguments: | ||
name The name of your application | ||
|
||
Options: | ||
-h --Help Show this screen. | ||
-v --version Show version. | ||
USAGE | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
module MRubyCLI | ||
class Help | ||
def initialize(output_io) | ||
def initialize(usage, output_io) | ||
@usage = usage | ||
@output_io = output_io | ||
end | ||
|
||
def run | ||
@output_io.puts "mruby-cli [switches] [arguments]" | ||
@output_io.puts "mruby-cli -h, --help : show this message" | ||
@output_io.puts "mruby-cli -s<name>, --setup=<name> : setup your app" | ||
@output_io.puts "mruby-cli -v, --version : print mruby-cli version" | ||
@output_io.puts @usage | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is there a way we can have this flag be autodetected instead of manually being added for anyone who wants to mruby-docopt?
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 just tried without it, and it failed.
http://ruby-doc.org/core-mruby/doc/guides/compile_md.html#label-C-2B-2B+ABI
So it should be detected automatically, moreover, I've enabled it into mruby-docopt. So it seems that it's too late when it detects and enables it.
Should
MRuby::Build
andMRuby::CrossBuild
configuration of mrbgems infect the project depending on them?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.
We should be able to add defines in the mrbgem.rake of mruby-docopt
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.
Could you explain @zzak ? How does it work?
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 dug into mruby code and find the following:
This issue is the same than previously. As the C++ code has been enabled, some files should be appropriately selected as for vm.cxx and error.cxx
y.tab.c
belongs to mruby-compiler. Its C++ version should be selected, it's not yet enabled when it comes to that gem, explaining why it fails.The patch I've mentioned above:
I don't like it at all, but it helps to understand the problem and what to do.
All of that makes me ask the following question: