Module: Ruflet::CLI::ExtraCommand
- Includes:
- FlutterSdk, NewCommand
- Included in:
- Ruflet::CLI
- Defined in:
- lib/ruflet/cli/extra_command.rb
Constant Summary
Constants included from NewCommand
NewCommand::CLIENT_EXTENSION_MAP, NewCommand::RUNTIME_REPO_URL, NewCommand::TEMPLATE_REPO_REF, NewCommand::TEMPLATE_REPO_URL
Constants included from FlutterSdk
FlutterSdk::DEFAULT_FLUTTER_CHANNEL, FlutterSdk::RELEASES_BASE
Instance Method Summary collapse
- #command_create(args) ⇒ Object
- #command_debug(args) ⇒ Object
- #command_devices(args) ⇒ Object
- #command_doctor(args) ⇒ Object
- #command_emulators(args) ⇒ Object
Methods included from NewCommand
Methods included from FlutterSdk
#ensure_flutter!, #flutter_version_summary
Instance Method Details
#command_create(args) ⇒ Object
11 12 13 |
# File 'lib/ruflet/cli/extra_command.rb', line 11 def command_create(args) command_new(args) end |
#command_debug(args) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/ruflet/cli/extra_command.rb', line 99 def command_debug(args) = { platform: nil, device_id: nil, release: false, verbose: false, web_renderer: nil } parser = OptionParser.new do |o| o.on("--platform NAME") { |v| [:platform] = v } o.on("--device-id ID") { |v| [:device_id] = v } o.on("--release") { [:release] = true } o.on("-v", "--verbose") { [:verbose] = true } o.on("--web-renderer NAME") { |v| [:web_renderer] = v } end parser.parse!(args) [:platform] ||= args.shift client_dir = detect_client_dir unless client_dir warn "Could not find Flutter client directory." warn "Set RUFLET_CLIENT_DIR or let Ruflet manage the client under ./build/client" warn "`ruflet debug` requires Flutter client source code." warn "For prebuilt clients, use: `ruflet run --web` or `ruflet run --desktop`." return 1 end tools = ensure_flutter!("debug", client_dir: client_dir) cmd = [tools[:flutter], "run"] cmd << "--release" if [:release] cmd << "-v" if [:verbose] cmd += ["--web-renderer", [:web_renderer]] if [:web_renderer] if [:device_id] cmd += ["-d", [:device_id]] else case [:platform] when "web" cmd += ["-d", "chrome"] when "macos", "windows", "linux" cmd += ["-d", [:platform]] when "ios", "android" # let flutter pick the default device end end system(tools[:env], *cmd, chdir: client_dir) $?.exitstatus || 1 end |
#command_devices(args) ⇒ Object
58 59 60 61 62 |
# File 'lib/ruflet/cli/extra_command.rb', line 58 def command_devices(args) tools = ensure_flutter!("devices") system(tools[:env], tools[:flutter], "devices", *args) $?.exitstatus || 1 end |
#command_doctor(args) ⇒ Object
15 16 17 18 19 20 21 22 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 |
# File 'lib/ruflet/cli/extra_command.rb', line 15 def command_doctor(args) verbose = args.delete("--verbose") || args.delete("-v") fix = args.delete("--fix") client_dir = detect_client_dir template_root = if fix ensure_cached_ruflet_client_template!(force: true, verbose: !!verbose) else resolve_ruflet_client_template_root end puts "Ruflet doctor" puts " Ruby: #{RUBY_VERSION}" puts " Flutter host target: #{flutter_host || 'unsupported'}" if template_root puts " Template: #{template_root}" revision = cached_template_revision if respond_to?(:cached_template_revision, true) puts " Template revision: #{revision}" if revision elsif fix warn " Template: missing" warn "Failed to fetch the Ruflet Flutter template from GitHub." return 1 else warn " Template: missing" warn "Run `ruflet doctor --fix` to fetch the Flutter template from GitHub." end puts " Ruby runtime: pub.dev package" if fix tools = ensure_flutter!("doctor", client_dir: client_dir, auto_install: true) else tools = flutter_tools(client_dir: client_dir, auto_install: false) unless tools warn " Flutter: missing" warn "Run `ruflet doctor --fix` to install the host-platform Flutter SDK from .fvmrc." return 1 end end puts " Flutter: #{flutter_version_summary(tools)}" ok = system(tools[:env], tools[:flutter], "doctor", *(verbose ? ["-v"] : [])) status = $?.exitstatus if $? status ||= ok ? 0 : 1 status end |
#command_emulators(args) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ruflet/cli/extra_command.rb', line 64 def command_emulators(args) tools = ensure_flutter!("emulators") action = nil emulator_id = nil verbose = false parser = OptionParser.new do |o| o.on("--create") { action = "create" } o.on("--delete") { action = "delete" } o.on("--start") { action = "start" } o.on("--emulator ID") { |v| emulator_id = v } o.on("-v", "--verbose") { verbose = true } end parser.parse!(args) case action when "start" unless emulator_id warn "Missing --emulator for start" return 1 end cmd = [tools[:flutter], "emulators", "--launch", emulator_id] cmd << "-v" if verbose system(tools[:env], *cmd) $?.exitstatus || 1 when "create", "delete" warn "ruflet emulators --#{action} is not implemented yet. Use your platform tools." 1 else cmd = [tools[:flutter], "emulators"] cmd << "-v" if verbose system(tools[:env], *cmd) $?.exitstatus || 1 end end |