Module: Ruflet::CLI::NewCommand
- Included in:
- Ruflet::CLI, ExtraCommand
- Defined in:
- lib/ruflet/cli/new_command.rb
Constant Summary collapse
- CLIENT_EXTENSION_MAP =
{ "ads" => { package: "flet_ads", alias: "ruflet_ads" }, "audio" => { package: "flet_audio", alias: "ruflet_audio" }, "audio_recorder" => { package: "flet_audio_recorder", alias: "ruflet_audio_recorder" }, "camera" => { package: "flet_camera", alias: "ruflet_camera" }, "charts" => { package: "flet_charts", alias: "ruflet_charts" }, "code_editor" => { package: "flet_code_editor", alias: "ruflet_code_editor" }, "color_pickers" => { package: "flet_color_pickers", alias: "ruflet_color_picker" }, "datatable2" => { package: "flet_datatable2", alias: "ruflet_datatable2" }, "flashlight" => { package: "flet_flashlight", alias: "ruflet_flashlight" }, "geolocator" => { package: "flet_geolocator", alias: "ruflet_geolocator" }, "lottie" => { package: "flet_lottie", alias: "ruflet_lottie" }, "map" => { package: "flet_map", alias: "ruflet_map" }, "permission_handler" => { package: "flet_permission_handler", alias: "ruflet_permission_handler" }, "secure_storage" => { package: "flet_secure_storage", alias: "ruflet_secure_storage" }, "video" => { package: "flet_video", alias: "ruflet_video" }, "webview" => { package: "flet_webview", alias: "ruflet_webview" } }.freeze
Instance Method Summary collapse
Instance Method Details
#command_new(args) ⇒ Object
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/new_command.rb', line 29 def command_new(args) app_name = args.shift if app_name.nil? || app_name.strip.empty? warn "Usage: ruflet new <appname>" return 1 end root = File.(app_name, Dir.pwd) if Dir.exist?(root) warn "Directory already exists: #{root}" return 1 end FileUtils.mkdir_p(root) File.write(File.join(root, "main.rb"), format(Ruflet::CLI::MAIN_TEMPLATE, app_title: humanize_name(File.basename(root)))) File.write(File.join(root, "Gemfile"), Ruflet::CLI::GEMFILE_TEMPLATE) File.write(File.join(root, "README.md"), format(Ruflet::CLI::README_TEMPLATE, app_name: File.basename(root))) write_default_ruflet_config(root, File.basename(root)) copy_default_project_assets(root) project_name = File.basename(root) puts "Run:" puts " cd #{project_name}" puts " bundle install" puts " bundle exec ruflet run main.rb" puts puts "Build:" puts " bundle exec ruflet build android --self" puts " bundle exec ruflet build ios --self" 0 end |