Module: Fronde::CLI::Commands
- Included in:
- App
- Defined in:
- lib/fronde/cli/commands.rb
Overview
Fronde commands
Instance Method Summary collapse
- #fronde_build ⇒ Object
- #fronde_help ⇒ Object
- #fronde_new ⇒ Object
- #fronde_open ⇒ Object
- #fronde_preview ⇒ Object
- #fronde_publish ⇒ Object
- #fronde_update ⇒ Object
Instance Method Details
#fronde_build ⇒ Object
33 34 35 36 37 |
# File 'lib/fronde/cli/commands.rb', line 33 def fronde_build @rake..build_all = true @rake['site:build'].invoke @options[:force] true end |
#fronde_help ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fronde/cli/commands.rb', line 69 def fronde_help # Try to find command in next argv, otherwise fallback again. @command = @argv.shift || 'basic' if @command == 'help' cmd_opt = OptParse.(@command) label = cmd_opt[:label] || @command output = [format_label(I18n.t('fronde.bin.usage', label:))] cmd = cmd_opt[:name] || @command output << format_label(I18n.t("fronde.bin.commands.#{cmd}")) output << OptParse.help_command_body(cmd) puts output.join true end |
#fronde_new ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fronde/cli/commands.rb', line 12 def fronde_new new_dir = @argv.first || 'my_fronde_website' FileUtils.mkdir new_dir Dir.chdir new_dir Helpers.init_config_file @options Fronde::CONFIG.reset # Correctly compute various path Helpers.init_rakefile init_rake @rake['org:install'].invoke @argv = ['src/index.org'] fronde_open end |
#fronde_open ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fronde/cli/commands.rb', line 49 def fronde_open editor = ENV['EDITOR'] || ENV['VISUAL'] || 'emacs' cmd = [editor] file_path = @argv.first || Dir.pwd unless File.file?(file_path) # file_path may be updated with title given in options file_path = create_new_file(file_path) # Only move to the end of file for new file. Let the editor handle # the best position for already existing files cmd << '+6' end cmd << file_path system(*cmd) end |
#fronde_preview ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/fronde/cli/commands.rb', line 39 def fronde_preview Thread.new do sleep 1 port = Fronde::CONFIG.get(%w[preview server_port], 5000) Helpers.launch_app_for_uri "http://127.0.0.1:#{port}/" end @rake['site:preview'].invoke true end |
#fronde_publish ⇒ Object
64 65 66 67 |
# File 'lib/fronde/cli/commands.rb', line 64 def fronde_publish @rake['sync:push'].invoke true end |
#fronde_update ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/fronde/cli/commands.rb', line 25 def fronde_update Helpers.init_rakefile init_rake @rake..build_all = true @rake['org:upgrade'].invoke true end |