You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Building the canonical hello world example in mruby-cli is quite simple. The two files of note from the generate skeleton are `mrblib/hello_world.rb` and `mrbgem.rake`. The CLI hooks into the `__main__` method defined here and passes all the arguments as `argv`.
44
+
45
+
`mrblib/hello_world.rb`:
46
+
```ruby
47
+
def__main__(argv)
48
+
puts"Hello World"
49
+
end
50
+
```
51
+
52
+
### Dependencies
53
+
The rubygems equivalent is mrbgems. [mgem-list](https://github.com/mruby/mgem-list) contains a list of mgems you can pull from. By default mruby does not include everything in the kitchen sink like MRI. This means to even get `puts`, we need to include the `mruby-print`. The list of core gems can be found [here](https://github.com/mruby/mruby/tree/master/mrbgems). Adding dependencies is simple, you just need to add a line near the bottom of your `mrbgem.rake` with the two arguments: name and where it comes from.
54
+
55
+
`mrbgem.rake`:
56
+
```ruby
57
+
MRuby::Gem::Specification.new('hello_world') do |spec|
The app is built from two parts a C wrapper in `tools/` and a mruby part in `mrblib/`. The C wrapper is fairly minimal and executes the `__main__` method in mruby and instantiates ARGV and passes it to the mruby code. The rest of the CLI is written in mruby. You can't have subfolders in `mrblib/` but you can have as many files in `mrblib/`. All these files are precompiled into mruby bytecode The build tool for mruby is written in CRuby (MRI).
69
+
39
70
### Testing
40
71
By default, `mruby-cli` generates two kinds of tests: mtest and bintest.
41
72
@@ -53,8 +84,9 @@ These are integration tests, are written in CRuby (MRI), and go in the `bintest/
53
84
$ docker-compose run bintest
54
85
```
55
86
56
-
### CLI Architecture
57
-
The app is built from two parts a C wrapper in `tools/` and a mruby part in `mrblib/`. The C wrapper is fairly minimal and executes the `__main__` method in mruby and instantiates ARGV and passes it to the mruby code. The rest of the CLI is written in mruby. The build tool for mruby is written in CRuby (MRI).
87
+
## Examples
88
+
*`mruby-cli` itself is an app generated by `mruby-cli`, so you can explore this repo on how to build one.
89
+
*[mruby-eso-research](https://github.com/hone/mruby-eso-research) - an app for managing crafting research in Elder Scrolls Online. It uses YAML as the data store.
58
90
59
91
## mruby-cli Development
60
92
This app is built as a mruby-cli app, so you just need to run: `docker-compose run compile` and find the binaries in the appropriate directories.
0 commit comments