| Class | Anvil::Console |
| In: |
anvilties/lib/console.rb
|
| Parent: | Object |
Anvil‘s console has several uses. By default it is used to start the application when it is called within the application directory. Example:
cd /path/to/your/app anvil
When provided a string value without spaces, a fresh anvil applications is created:
cd /path/to/your anvil app cd app anvil
Those commands should give you a fresh application and fire up a blank window
For additional help, you can run
anvil -h
# File anvilties/lib/console.rb, line 52
52: def parse_opts(argv = ARGV)
53: options = {}
54:
55: options[:start_anvil] = true
56:
57: opts = OptionParser.new do |opts|
58: opts.banner = "Usage: anvil [gih] [argument]"
59: opts.define_head "Anvil GUI framework."
60: opts.separator '*'*80
61: opts.separator 'If no flags are given, Anvil starts in the foreground'
62: opts.separator '*'*80
63:
64: opts.on("-i", "--irb-console", "This flag will start Anvil in irb console. Your application models and classes will be loaded and available through console.") do |console|
65: options[:console] = true
66: options[:start_anvil] = false
67: puts "Coming Soon!"
68: end
69:
70: opts.on("-g", "--generate-app PATH", "Generate a fresh Anvil application at PATH") do |path|
71: options[:generate] = path || Dir.pwd
72: options[:start_anvil] = false
73: end
74:
75: opts.on("-?", "-h", "--help", "Show this help message") do
76: puts opts
77: exit
78: end
79: end
80:
81: opts.parse!(argv)
82:
83: # anvil <argument> is the same as anvil -g <argument>
84: if argv.size == 1
85: options[:generate] = File.expand_path(argv.last)
86: options[:start_anvil] = false
87: end
88:
89: @@anvil_opts = options
90: end
# File anvilties/lib/console.rb, line 33
33: def run
34: parse_opts
35:
36: # Start Anvil when option is set
37: Anvil::Initializer.run if @@anvil_opts[:start_anvil] || @@anvil_opts[:console]
38:
39: # Generate fresh Anvil Application if option is set
40: if @@anvil_opts[:generate]
41: Anvil::AppGenerator.run @@anvil_opts[:generate]
42: exit!
43:
44: # Initialize irb console if option is set
45: elsif @@anvil_opts[:console]
46: ARGV.clear
47: require 'irb'
48: require 'irb/completion'
49: end
50: end