Class: Flutterby::CLI
- Inherits:
-
Thor
- Object
- Thor
- Flutterby::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/flutterby/cli.rb
Instance Method Summary collapse
Instance Method Details
#build ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/flutterby/cli.rb', line 28 def build Flutterby.logger.level = .debug ? Logger::DEBUG : Logger::INFO # Simplify logger output Flutterby.logger.formatter = proc do |severity, datetime, progname, msg| " • #{msg}\n" end say_hi time = Benchmark.realtime do # Import site say color("📚 Importing site...", :bold) root = Flutterby::Node.new("/", fs_path: .in) root.stage! say color("🌲 Read #{root.tree_size} nodes.", :green, :bold) # Export site say color("💾 Exporting site...", :bold) Flutterby::Exporter.new(root).export!(into: .out) end say color("✅ Done. (took #{sprintf "%.2f", time}s)", :green, :bold) end |
#new(path) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/flutterby/cli.rb', line 76 def new(path) say_hi path = File.(path) self.destination_root = path say color("🏗 Creating a new Flutterby project in #{path}...", :bold) directory("new_project", path) chmod("bin/flutterby", 0755) chmod("bin/rake", 0755) in_root { bundle_install } end |
#serve ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/flutterby/cli.rb', line 59 def serve Flutterby.logger.level = .debug ? Logger::DEBUG : Logger::INFO say_hi say color("📚 Importing site...", :bold) root = Flutterby::Node.new("/", fs_path: .in) root.stage! say color("🌲 Read #{root.tree_size} nodes.", :green, :bold) say color("🌤 Serving your Flutterby site on http://localhost:#{.port} - enjoy! \\o/", :bold) server = Flutterby::Server.new(root) server.run!(port: .port) end |
#version ⇒ Object
19 20 21 |
# File 'lib/flutterby/cli.rb', line 19 def version say_hi end |