Module: Drakkon::Images::CLI
- Defined in:
- lib/drakkon/lib/images/cli.rb
Overview
General Entry Point For Images Subcommand
Class Method Summary collapse
-
.menu ⇒ Object
rubocop:disable Metrics/BlockLength.
-
.prompt ⇒ Object
rubocop:enable Metrics/BlockLength.
- .run!(args = []) ⇒ Object
-
.start(cmd, args) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
Class Method Details
.menu ⇒ Object
rubocop:disable Metrics/BlockLength
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/drakkon/lib/images/cli.rb', line 54 def self. prompt.select('Image Helpers:', filter: true, per_page: 20) do || .choice name: 'Listing; Filter', value: :list .choice name: 'Biggest: Find largest dimensions [biggest]', value: :biggest .choice name: 'Convert alpha to white [white]', value: :white .choice name: 'Resize WxH [resize]', value: :resize .choice name: 'Scale [scale]', value: :scale .choice name: 'Shift (Splice/Gravity) [shift]', value: :shift .choice name: 'Roll [roll]', value: :roll .choice name: 'Flip/Flop [flip_flop]', value: :flip_flop .choice name: 'Rotate [rotate]', value: :rotate .choice name: 'Canvas (Change/Retain) [canvas]', value: :canvas .choice name: 'Desaturate (Grey Colorspace) [desaturate]', value: :desaturate .choice name: 'Blur [blur]', value: :blur .choice name: 'Split SpriteSheet [split]', value: :split .choice name: 'Create SpriteSheet [combine]', value: :combine .choice name: 'Double Image [double]', value: :double .choice name: 'Trim Transparency (:trim]', value: :trim .choice name: 'Gif Split [gif_split]', value: :gif_split .choice name: 'Sepia [sepia]', value: :sepia .choice name: 'Modulate [modulate]', value: :modulate .choice name: 'Layers [layers]', value: :layers .choice name: 'Bulk Rename [bulk_rename]', value: :bulk_rename .choice name: 'Downcase Normalize [downcase_norm]', value: :downcase_norm .choice name: 'Hue Modulate [hue_modulate]', value: :hue_modulate .choice name: 'TextToImage [text_to_image]', value: :text_to_image .choice name: 'Compress (file size) [compress]', value: :compress .choice name: 'Index (Re-run Index) [index]', value: :index .choice name: 'exit', value: :exit end rescue TTY::Reader::InputInterrupt exit 0 end |
.prompt ⇒ Object
rubocop:enable Metrics/BlockLength
89 90 91 |
# File 'lib/drakkon/lib/images/cli.rb', line 89 def self.prompt TTY::Prompt.new(active_color: :cyan, interrupt: :exit) end |
.run!(args = []) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/drakkon/lib/images/cli.rb', line 5 def self.run!(args = []) args ||= [] cmd = if args.empty? nil else args.shift.to_sym end start(cmd, args) end |
.start(cmd, args) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
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 |
# File 'lib/drakkon/lib/images/cli.rb', line 16 def self.start(cmd, args) case cmd when :list then Images::List.run!(args) when :biggest then Images::Biggest.run!(args) when :white then Images::White.run!(args) when :resize then Images::Resize.run!(args) when :shift then Images::Shift.run!(args) when :roll then Images::Roll.run!(args) when :scale then Images::Scale.run!(args) when :flip_flop then Images::FlipFlop.run!(args) when :rotate then Images::Rotate.run!(args) when :canvas then Images::Canvas.run!(args) when :desaturate then Images::Desaturate.run!(args) when :blur then Images::Blur.run!(args) when :split then Images::SplitSpriteSheet.run!(args) when :combine then Images::SpriteSheetCombine.run!(args) when :double then Images::Double.run!(args) when :trim then Images::Trim.run!(args) when :gif_split then Images::GifSplit.run!(args) when :sepia then Images::Sepia.run!(args) when :modulate then Images::Modulate.run!(args) when :layers then Images::Layers.run!(args) when :hue_modulate then Images::HueModulate.run!(args) when :bulk_rename then Images::BulkRename.run!(args) when :downcase_norm then Images::DowncaseNormalize.run!(args) when :text_to_image then Images::TextToImage.run!(args) when :compress then Images::Compress.run!(args) when :index then Images::Index.run!(force: true) when :exit then exit(0) else start(, args) end rescue TTY::Reader::InputInterrupt exit 0 end |