Upgrade to Pro — share decks privately, control downloads, hide ads and more …

mruby-cliでCLIを作りたかった話

tsubasa
August 04, 2017

 mruby-cliでCLIを作りたかった話

社内勉強会で話したやつ

tsubasa

August 04, 2017
Tweet

More Decks by tsubasa

Other Decks in Technology

Transcript

  1. ؀ڥߏங  $ curl -L -o mruby.zip https: //github.com/mruby/mruby/archive/1.3.0.zip $

    unzip mruby.zip $ cd mruby-1.3.0 $ ruby ./minirake $ bin/mirb mirb - Embeddable Interactive Ruby Shell > puts 'Hello, world!' Hello, world!
  2. ؀ڥߏங  $ docker docker run -it tsub/mruby mirb mirb

    - Embeddable Interactive Ruby Shell > puts 'Hello, world!' Hello, world! => nil
  3. ؀ڥߏங  $ curl -L -o mruby-cli.tgz https: //github.com/hone/mruby-cli/releases/download/ v0.0.4/mruby-cli-0.0.4-x86_64-apple-darwin14.tgz

    $ tar -zxvf mruby-cli.tgz $ mruby-cli --setup my-cli ॳظϑΝΠϧΛੜ੒ͨ͠ΒNSVCZDMJͷ໾ׂ͸ऴΘΓ
  4. ؀ڥߏங  $ docker run -it -v $PWD:$PWD -w $PWD

    tsub/mruby-cli --setup my-cli $ whalebrew install tsub/mruby-cli $ mruby-cli --setup my-cli 8IBMFCSFXΛ࢖͏ͱ΋ͬͱΧϯλϯʢએ఻ʣ
  5. σΟϨΫτϦߏ੒  $ tree mycli/ mycli/ ├── Dockerfile ├── Rakefile

    ├── bintest │ └── my-cli.rb ├── build_config.rb ├── docker-compose.yml ├── mrbgem.rake ├── mrblib │ ├── my-cli │ │ └── version.rb │ └── my-cli.rb ├── test │ └── test_my-cli.rb └── tools └── my-cli └── my-cli.c
  6. Ϗϧυ  $ cd my-cli $ docker-compose run compile $

    mruby/build/x86_64-apple-darwin14/bin/my-cli Hello World %PDLFSͰΫϩείϯύΠϧָ͕ͪΜ
  7.  $ docker-compose run compile ... rake aborted! Command failed

    with status (127): [clang -g -std=gnu99 -O3 -Wall -Werror-impl ...] /home/mruby/code/mruby/tasks/mruby_build_commands.rake:31:in `_run' /home/mruby/code/mruby/tasks/mruby_build_commands.rake:36:in `rescue in _run' /home/mruby/code/mruby/tasks/mruby_build_commands.rake:32:in `_run' /home/mruby/code/mruby/tasks/mruby_build_commands.rake:88:in `run' /home/mruby/code/mruby/tasks/mruby_build_commands.rake:123:in `block (2 levels) in define_rules' Command failed with status (127): ["clang" -g -std=gnu99 -O3 -Wall -Werror-im ...] /home/mruby/code/mruby/tasks/mruby_build_commands.rake:33:in `_run' /home/mruby/code/mruby/tasks/mruby_build_commands.rake:88:in `run' /home/mruby/code/mruby/tasks/mruby_build_commands.rake:123:in `block (2 levels) in define_rules' Tasks: TOP => compile => all => /home/mruby/code/mruby/build/host/lib/libmruby.flags.mak => /home/mruby/code/mruby/build/host/lib/libmruby.a => /home/mruby/code/mruby/build/host/ mrbgems/mruby-httprequest/gem_init.o (See full trace by running task with --trace)
  8.  host = 'https: //hogebucket.s3.amazonaws.com' HttpsClient.new.get(host) { |response| puts response.body

    } <?xml version="1.0" encoding="UTF-8"?><Error><Code>HttpVersionNotSupported </ Code><Message>The HTTP version specified is not supported. </ Message><RequestId>D4E14016402FF617 </ RequestId><HostId>FqG1atM6CjvM6KDJsy7sGjCEeNs0RMmMINJ8o9MtzrFclhMPYiCzyUw5HVSwR/ VG1ecALwzspOpjjLGk3NaglQE36X8O5+wN </HostId> </Error> Α͘Θ͔Βͳ͍ΤϥʔʢϥΠϒϥϦͷ͍ͤʁʣ ͦΕͬΆ͍࣮૷
  9. 

  10. )BDPOJXBͱ͸ w ϖύϘͷਓ͕ओʹ࡞ͬͯΔ w ίϯςφΤϯδϯ ଞʹ%PDLFS -9$ SLUͳͲ  w

    'BTU$POUBJOFSΞʔΩςΫνϟΛ࣮ݱ͢ΔͨΊͷ΋ͷ w ࣮ࡍʹ΋͏ϖύϘͷαʔϏεʹࡌ͍ͬͯΔ Ϋϩʔζυϕʔλ