Module: Ruflet::CLI

Extended by:
CLI, BuildCommand, ExtraCommand, NewCommand, RunCommand, UpdateCommand
Included in:
CLI
Defined in:
lib/ruflet/cli.rb,
lib/ruflet/cli/templates.rb,
lib/ruflet/cli/flutter_sdk.rb,
lib/ruflet/cli/new_command.rb,
lib/ruflet/cli/run_command.rb,
lib/ruflet/cli/build_command.rb,
lib/ruflet/cli/extra_command.rb,
lib/ruflet/cli/update_command.rb

Defined Under Namespace

Modules: BuildCommand, ExtraCommand, FlutterSdk, NewCommand, RunCommand, UpdateCommand

Constant Summary collapse

MAIN_TEMPLATE =
<<~RUBY
require "ruflet"
Ruflet.run do |page|
  page.title = "Counter Demo"
  count = 0
  count_text = text(count.to_s, style: {size: 40})
  page.add(
    container(
      expand: true,
      alignment: Ruflet::MainAxisAlignment::CENTER,
      content: column(
        alignment: Ruflet::MainAxisAlignment::CENTER,
        horizontal_alignment: Ruflet::CrossAxisAlignment::CENTER,
        children: [
          text("You have pushed the button this many times:"),
          count_text
        ]
      )
    ),
    floating_action_button: fab(
      icon: "add",
      on_click: ->(_e) do
        count += 1
        page.update(count_text, value: count.to_s)
      end
    )
  )
end

RUBY
GEMFILE_TEMPLATE =
<<~GEMFILE
  source "https://rubygems.org"

  gem "ruflet_core", ">= 0.0.10"
  gem "ruflet_server", ">= 0.0.10"
GEMFILE
README_TEMPLATE =
<<~MD
  # %<app_name>s

  Ruflet app.

  ## Setup

  ```bash
  bundle install
  ```

  ## Run

  ```bash
  bundle exec ruflet run main
  ```

  ## Build

  ```bash
  bundle exec ruflet build apk
  bundle exec ruflet build ios
  ```
MD

Constants included from NewCommand

NewCommand::CLIENT_EXTENSION_MAP

Constants included from UpdateCommand

UpdateCommand::VALID_UPDATE_PLATFORMS

Constants included from BuildCommand

BuildCommand::CLIENT_EXTENSION_MAP

Constants included from FlutterSdk

FlutterSdk::DEFAULT_FLUTTER_CHANNEL, FlutterSdk::RELEASES_BASE

Instance Method Summary collapse

Methods included from NewCommand

command_new

Methods included from RunCommand

command_run

Methods included from UpdateCommand

command_update

Methods included from BuildCommand

command_build, command_install

Methods included from FlutterSdk

#ensure_flutter!, #flutter_version_summary

Methods included from ExtraCommand

command_create, command_debug, command_devices, command_doctor, command_emulators

Instance Method Details

#bootstrap(path) ⇒ Object



79
80
81
82
# File 'lib/ruflet/cli.rb', line 79

def bootstrap(path)
  command_new([path || Dir.pwd])
  0
end


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ruflet/cli.rb', line 60

def print_help
  puts <<~HELP
    Ruflet CLI

    Commands:
      ruflet --version
      ruflet create <appname>
      ruflet new <appname>
      ruflet run [scriptname|path] [--web|--desktop] [--port PORT]
      ruflet update [web|desktop|all] [--check] [--force] [--platform PLATFORM]
      ruflet debug [scriptname|path]
      ruflet build <apk|android|ios|aab|web|macos|windows|linux> [--self] [--verbose]
      ruflet install [--device DEVICE_ID] [--verbose]
      ruflet devices
      ruflet emulators
      ruflet doctor
  HELP
end

#run(argv = ARGV) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ruflet/cli.rb', line 23

def run(argv = ARGV)
  command = (argv.shift || "help").downcase

  case command
  when "version", "-v", "--version"
    puts version_string
    0
  when "create"
    command_create(argv)
  when "new", "bootstrap", "init"
    command_new(argv)
  when "run"
    command_run(argv)
  when "update"
    command_update(argv)
  when "debug"
    command_debug(argv)
  when "build"
    command_build(argv)
  when "install"
    command_install(argv)
  when "devices"
    command_devices(argv)
  when "emulators"
    command_emulators(argv)
  when "doctor"
    command_doctor(argv)
  when "help", "-h", "--help"
    print_help
    0
  else
    warn "Unknown command: #{command}"
    print_help
    1
  end
end

#version_stringObject



84
85
86
# File 'lib/ruflet/cli.rb', line 84

def version_string
  "ruflet #{Ruflet::VERSION}"
end