Class: Muvy::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/muvy/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mediaObject (readonly)

Returns the value of attribute media.



7
8
9
# File 'lib/muvy/cli.rb', line 7

def media
  @media
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/muvy/cli.rb', line 7

def options
  @options
end

Instance Method Details

#parseObject



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
57
58
59
60
61
62
63
64
# File 'lib/muvy/cli.rb', line 17

def parse
  @options = Slop.parse do |o|
    o.banner = "Usage: muvy [media link, file, or file path] [options]"

    o.separator ""
    o.separator "Optional adjustments:"
    o.string  "-p", "--path", "Directory to save final images, " +
              "\n\t\t\s\s\s\sDefault: your pwd → #{Dir.pwd}",
              default: Dir.pwd
    o.string  "-s", "--style", "Choose a style: solid, stretch " +
              "\n\t\t\s\s\s\sDefault: solid",
              default: "solid"
    o.string  "-g", "--gradient", "Add a gradient over the final image" +
              "\n\t\t\s\s\s\sChoose one from: black:heavy black:medium black:light" +
              "\n\t\t\s\s\s\s\t\t\s\s\s\s\swhite:heavy white:medium white:light" +
              "\n\t\t\s\s\s\sDefault: none"
    o.string  "-a", "--arc", "Wrap all of the lines around a center point" +
              "\n\t\t\s\s\s\sChoose a style: circle, iris" +
              "\n\t\t\s\s\s\sDefault: none"
    o.boolean "-r", "--rotate", "Image will have horizontal lines"
    o.integer "-h", "--height", "Custom height of the final image"
    o.string "--start", "Custom video start time"
    o.string "--end", "Custom video end time"
    o.string "--format", "Force youtube-dl to use a specific video quality"
    o.string "--frame_rate", <<~FPS
      Set a custom frame rate. Be careful!
      \t\t\s\s\s\sSetting this to a high number might cause hundreds of
      \t\t\s\s\s\sthousands of images to be generated in your sytem's temp dir.
      \t\t\s\s\s\sThe specific frame_rate used by default for your file is printed
      \t\t\s\s\s\safter generation. You can use that number to make a reasonable change.
    FPS

    o.separator "More:"
    o.on "--help", "Shows this usage page" do
      abort o.to_s
    end

    o.on "-v", "--version", "Displays the version" do
      abort "muvy version #{VERSION}"
    end
  end
rescue Slop::Error => e
  abort <<~ERROR
    #{e}.
    Type `muvy --help` to see options, or visit the
    github repo for extensive usage examples.
  ERROR
end

#startObject



9
10
11
12
13
14
15
# File 'lib/muvy/cli.rb', line 9

def start
  parse
  handle_media
  handle_path
  convert_options
  read_media
end