moshy 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 01a2d4b1a7da07ede5233ef927810cc9c2ad22dc
4
- data.tar.gz: 25f1da8cb50e198ff6d73e63cfdbda58ecdc0703
2
+ SHA256:
3
+ metadata.gz: edf65fecfa904ea31534e576836c26e9e044bd98f1366effca7547202c099ac3
4
+ data.tar.gz: c5d56088d7a9c84c55720ee6fe839e88cbb1cd9af3eef7ba0f712496af867e85
5
5
  SHA512:
6
- metadata.gz: 4e8ce36d5840438cf53541ad9ef9cd7b0f4f00cebea8819f33f45be8d6d1c43a795db9455b05648045042ff5408e59738e24a318f6ce045fae9540492801b998
7
- data.tar.gz: 6ca6009760d2cea4a35792ba439054d4870a663dc27b8337d10d26df0d63212c1ed2026ac33b5f67cb00bdb24b4d5ea586017f08b4ae2d763a0bce378e11042f
6
+ metadata.gz: 38e68fc229fb0e00cafb669bb2239ac24ec982aef442dabbeba00c2647bf81270627c36eae86664f39e252dbba8e407f9427661a8f4201765c43bff6f2cb2ee3
7
+ data.tar.gz: a3656dfab4e713f695d443f825e46c92b3b3c4e6f93593b35034cb9118820c48b2370733b1c2ccfe3479650e517f89267050f8793116585537b91badb9aca310
data/.gitignore CHANGED
@@ -1,22 +1,22 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.bundle
19
- *.so
20
- *.o
21
- *.a
22
- mkmf.log
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/DEVNOTES.md ADDED
@@ -0,0 +1,7 @@
1
+ # Running on Windows 10
2
+
3
+ Need to have PATH set up properly with ffmpeg
4
+
5
+ ```
6
+ ruby -Ilib ./bin/moshy -m prep -i i.mp4 -o o.avi
7
+ ```
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in moshy.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in moshy.gemspec
4
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2015 Way Spurr-Chen <wayspurrchen@gmail.com> <http://wayspurrchen.com/>
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2015 Way Spurr-Chen <wayspurrchen@gmail.com> <http://wayspurrchen.com/>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,87 +1,94 @@
1
- # moshy
2
-
3
- ![](http://imgur.com/OMLTr26.gif)
4
- created with moshy's pdupe options
5
-
6
- **moshy** is a command line datamoshing utility kit for AVI files, based heavily on [aviglitch](https://github.com/ucnv/aviglitch).
7
- It's designed to make common datamoshing tasks easier without having to open avidemux or other GUI tools. It lets you do stuff like:
8
-
9
- - Convert video files into AVI video files with minimal I-Frames and no B-frames for ultimate moshability
10
- - Create P-Frame duplication effects quickly
11
- - Split a long video file into multiple clips based on its I-Frames
12
- - "Bake" your datamoshed video, encoding the corruption as actual video content for uploading to video services or moshing even further!
13
- - Identifying keyframe and deltaframe indexes in any AVI file
14
- - ...and more!
15
-
16
- If you don't know how to use the command line, this is a great opportunity to learn:
17
-
18
- - Mac OS X Tutorial: http://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line
19
- - Windows Tutorial: http://lifehacker.com/5633909/who-needs-a-mouse-learn-to-use-the-command-line-for-almost-anything
20
-
21
- ## Get it!
22
-
23
- You'll need to install [Ruby](https://www.ruby-lang.org/en/). If you're on Mac OS X, you probably already have a local version of Ruby installed. Once that's done, you can use Rubygems (which comes with Ruby) to install moshy:
24
-
25
- ```
26
- gem install moshy
27
- ```
28
-
29
- From there, you can use `moshy` from the command line.
30
-
31
- ## What's it do?
32
-
33
- Moshy currently has six different modes:
34
-
35
- - `prep` - Preps a video file for datamoshing with moshy by converting it
36
- into an AVI with no B-Frames (they're not good for moshing), and placing as
37
- few I-Frames as possible. Requires ffmpeg be installed locally.
38
- - `isplit` - Extracts individual clips from an AVI where each clip is
39
- separated by I-frames in the original AVI. Great for getting specific
40
- clips out of a larger video and later doing I-frame moshing.
41
- - `inspect` - Reads an .avi file and prints which video frames are keyframes
42
- (I-Frames) and which frames are delta frames (P-frames or B-frames). moshy
43
- cannot tell the difference between a P-frame or a B-frame, so you will want
44
- to use avidemux or another program if you need to know.
45
- - `pdupe` - Duplicates a P-frame at a given frame a certain amount. To find
46
- out which frames are P-frames, use software like avidemux to look at the
47
- frame type. WARNING: This mode is a little glitchy. You may need to set
48
- the interval 1 or 2 above or below the frame number you actually want to
49
- duplicate. I'm not sure why this happens, but try it with a small
50
- duplication amount first. NOTE: This can mode take a while to process
51
- over 60-90 frame dupes.
52
- - `ppulse` - Takes c number of frames and every n frames and duplicates them a
53
- given amount, resulting in a consistent P-duplication datamosh that's
54
- good for creating rhythmic effects. This was originally created to
55
- create mosh effects in sync with a beat for a music video.
56
- - `bake` - "Bakes" your datamosh by creating a new video file from your
57
- datamoshed .avi, causing the datamosh effects to be treated as the actual
58
- content of the new video instead of an error. Requires ffmpeg to be
59
- installed locally.
60
-
61
- You can access detailed info on how to use each of them from the command line with
62
- the command `moshy -m <mode> --help`.
63
-
64
- ## Cool!
65
-
66
- If you think this is cool, you'll probably find my list of [glitch art resources](http://www.glitchet.com/resources)
67
- useful as well as the [Glitchet newsletter](http://www.glitchet.com/), a free weekly futuristic
68
- news and glitch aesthetic e-zine.
69
-
70
- ## Quick tutorial
71
-
72
- Here's a short example of how you might use moshy to create a P-dupe mosh:
73
-
74
- 1. Choose a YouTube video you want to mosh (I'll use "Charlie bit my finger": <https://www.youtube.com/watch?v=bnRVheEpJG4>)
75
- 2. Download it with KeepVid (<http://keepvid.com/?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbnRVheEpJG4>)
76
- 3. "Prep" it with moshy to turn it into an .AVI with minimal I-Frames and all P-frames (because B-frames don't mosh well):
77
- `moshy -m prep -i charlie.mp4 -o charlie.avi`
78
- 4. Open charlie.avi in avidemux and clip it down to the segment I want (moshy will soon be able to do this with a "clip" command): ![](http://i.imgur.com/OBy8pbB.png)
79
- 5. Open charlie_clip.avi and find the frame I want to P-dupe mosh (here, frame 196): ![](http://i.imgur.com/aZsZIx6.png)
80
- 6. Use moshy in pdupe mode to dupe frame 196 60 times:
81
- `moshy -m pdupe -i charlie_clip.avi -f 196 -d 60 -o charlie_clip-dupe.avi`
82
- Open it in a video player (I use VLC) and see if it looks good.
83
- 7. Awesome, I love it, but I want to clip it down to size. However, since it has so few I-frames, if I just clip it anywhere, the beginning of the video will become corrupted because of lack of pixel data. Let's use moshy to bake the mosh:
84
- `moshy -m bake -i charlie_clip-dupe.avi -o charlie_clip-dupe-bake.avi`
85
- 8. Done. Let's open it back up in avidemux, clip it down to size, and save our final result: ![](http://i.imgur.com/07abIqT.png)
86
- 9. Looks good to me. Let's save it as an MP4 so that I can upload it to Giphy, which will convert it into a .gif for me. (I'm hoping to add modes to moshy that convert videos to .gif and .mp4 directly, too.)
87
- 10. Done! ![](https://media.giphy.com/media/3o85xoWYyG1HEVs8Vy/giphy.gif)
1
+ # moshy
2
+
3
+ ![](http://imgur.com/OMLTr26.gif)
4
+ created with moshy's pdupe options
5
+
6
+ **moshy** is a command line datamoshing utility kit for AVI files, based heavily on [aviglitch](https://github.com/ucnv/aviglitch).
7
+ It's designed to make common datamoshing tasks easier without having to open avidemux or other GUI tools. It lets you do stuff like:
8
+
9
+ - Convert video files into AVI video files with minimal I-Frames and no B-frames for ultimate moshability
10
+ - Create P-Frame duplication effects quickly
11
+ - Split a long video file into multiple clips based on its I-Frames
12
+ - "Bake" your datamoshed video, encoding the corruption as actual video content for uploading to video services or moshing even further!
13
+ - Identifying keyframe and deltaframe indexes in any AVI file
14
+ - ...and more!
15
+
16
+ If you don't know how to use the command line, this is a great opportunity to learn:
17
+
18
+ - Mac OS X Tutorial: http://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line
19
+ - Windows Tutorial: http://lifehacker.com/5633909/who-needs-a-mouse-learn-to-use-the-command-line-for-almost-anything
20
+
21
+ ## Get it!
22
+
23
+ You'll need to install [Ruby](https://www.ruby-lang.org/en/). If you're on Mac OS X, you probably already have a local version of Ruby installed. Once that's done, you can use Rubygems (which comes with Ruby) to install moshy:
24
+
25
+ ```
26
+ gem install moshy
27
+ ```
28
+
29
+ From there, you can use `moshy` from the command line.
30
+
31
+ For a couple commands (`prep` and `bake`), you need to have ffmpeg installed locally.
32
+ [You can get it for your OS here.](https://www.ffmpeg.org/download.html)
33
+
34
+ ## What's it do?
35
+
36
+ Moshy currently has six different modes:
37
+
38
+ - `prep` - Preps a video file for datamoshing with moshy by converting it
39
+ into an AVI with no B-Frames (they're not good for moshing), and placing as
40
+ few I-Frames as possible. Requires ffmpeg be installed locally.
41
+ - `isplit` - Extracts individual clips from an AVI where each clip is
42
+ separated by I-frames in the original AVI. Great for getting specific
43
+ clips out of a larger video and later doing I-frame moshing.
44
+ - `inspect` - Reads an .avi file and prints which video frames are keyframes
45
+ (I-Frames) and which frames are delta frames (P-frames or B-frames). moshy
46
+ cannot tell the difference between a P-frame or a B-frame, so you will want
47
+ to use avidemux or another program if you need to know.
48
+ - `pdupe` - Duplicates a P-frame at a given frame a certain amount. To find
49
+ out which frames are P-frames, use software like avidemux to look at the
50
+ frame type. WARNING: This mode is a little glitchy. You may need to set
51
+ the interval 1 or 2 above or below the frame number you actually want to
52
+ duplicate. I'm not sure why this happens, but try it with a small
53
+ duplication amount first. NOTE: This can mode take a while to process
54
+ over 60-90 frame dupes.
55
+ - `ppulse` - Takes c number of frames and every n frames and duplicates them a
56
+ given amount, resulting in a consistent P-duplication datamosh that's
57
+ good for creating rhythmic effects. This was originally created to
58
+ create mosh effects in sync with a beat for a music video.
59
+ - `bake` - "Bakes" your datamosh by creating a new video file from your
60
+ datamoshed .avi, causing the datamosh effects to be treated as the actual
61
+ content of the new video instead of an error. Requires ffmpeg to be
62
+ installed locally.
63
+
64
+ You can access detailed info on how to use each of them from the command line with
65
+ the command `moshy -m <mode> --help`.
66
+
67
+ ## Cool!
68
+
69
+ If you think this is cool, you'll probably find my list of [glitch art resources](http://www.glitchet.com/resources)
70
+ useful as well as the [Glitchet newsletter](http://www.glitchet.com/), a free weekly futuristic
71
+ news and glitch aesthetic e-zine.
72
+
73
+ ## Quick tutorial
74
+
75
+ Here's a short example of how you might use moshy to create a P-dupe mosh:
76
+
77
+ 1. Choose a YouTube video you want to mosh (I'll use "Charlie bit my finger": <https://www.youtube.com/watch?v=bnRVheEpJG4>)
78
+ 2. Download it with KeepVid (<http://keepvid.com/?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbnRVheEpJG4>)
79
+ 3. "Prep" it with moshy to turn it into an .AVI with minimal I-Frames and all P-frames (because B-frames don't mosh well):
80
+ `moshy -m prep -i charlie.mp4 -o charlie.avi`
81
+ 4. Open charlie.avi in avidemux and clip it down to the segment I want (moshy will soon be able to do this with a "clip" command): ![](http://i.imgur.com/OBy8pbB.png)
82
+ 5. Open charlie_clip.avi and find the frame I want to P-dupe mosh (here, frame 196): ![](http://i.imgur.com/aZsZIx6.png)
83
+ 6. Use moshy in pdupe mode to dupe frame 196 60 times:
84
+ `moshy -m pdupe -i charlie_clip.avi -f 196 -d 60 -o charlie_clip-dupe.avi`
85
+ Open it in a video player (I use VLC) and see if it looks good.
86
+ 7. Awesome, I love it, but I want to clip it down to size. However, since it has so few I-frames, if I just clip it anywhere, the beginning of the video will become corrupted because of lack of pixel data. Let's use moshy to bake the mosh:
87
+ `moshy -m bake -i charlie_clip-dupe.avi -o charlie_clip-dupe-bake.avi`
88
+ 8. Done. Let's open it back up in avidemux, clip it down to size, and save our final result: ![](http://i.imgur.com/07abIqT.png)
89
+ 9. Looks good to me. Let's save it as an MP4 so that I can upload it to Giphy, which will convert it into a .gif for me. (I'm hoping to add modes to moshy that convert videos to .gif and .mp4 directly, too.)
90
+ 10. Done! ![](https://media.giphy.com/media/3o85xoWYyG1HEVs8Vy/giphy.gif)
91
+
92
+ ## Trouble?
93
+
94
+ Having issues? Please [file an issue](https://github.com/wayspurrchen/moshy/issues/new)!
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require "bundler/gem_tasks"
2
+
data/bin/moshy CHANGED
@@ -1,105 +1,107 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'optparse'
4
- require 'slop'
5
- require 'moshy'
6
-
7
- module Moshy
8
- def self.top_level_help
9
- $options = {
10
-
11
- }
12
- opts = OptionParser.new do |opts|
13
- opts.banner = "
14
- moshy, a Ruby utility for making it easier to datamosh AVI files. It has
15
- multiple modes that can be run with the -m or --mode option.
16
-
17
- MODES DETAILS
18
- -------------
19
-
20
- \"prep\"
21
- ------
22
- Preps a video file for datamoshing with moshy by converting it
23
- into an AVI with no B-Frames (they're not good for moshing), and placing as
24
- few I-Frames as possible. Requires ffmpeg be installed locally.
25
-
26
- \"isplit\"
27
- --------
28
- Extracts individual clips from an AVI where each clip is
29
- separated by I-frames in the original AVI. Great for getting specific
30
- clips out of a larger video and later doing I-frame moshing.
31
-
32
- \"pdupe\"
33
- -------
34
- Duplicates a P-frame at a given frame a certain amount. To find
35
- out which frames are P-frames, use software like avidemux to look at the
36
- frame type. WARNING: This mode is a little glitchy. You may need to set
37
- the interval 1 or 2 above or below the frame number you actually want to
38
- duplicate. I'm not sure why this happens, but try it with a small
39
- duplication amount first. NOTE: This can mode take a while to process
40
- over 60-90 frame dupes.
41
-
42
- \"ppulse\"
43
- --------
44
- Takes c number of frames and every n frames and duplicates them a
45
- given amount, resulting in a consistent P-duplication datamosh that's
46
- good for creating rhythmic effects. This was originally created to
47
- create mosh effects in sync with a beat for a music video.
48
-
49
- \"bake\"
50
- ------
51
- \"Bakes\" your datamosh by creating a new video file from your
52
- datamoshed .avi, causing the datamosh effects to be treated as the actual
53
- content of the new video instead of an error. Requires ffmpeg to be
54
- installed locally.
55
-
56
- \"inspect\"
57
- ---------
58
- Reads an .avi file and prints which video frames are keyframes
59
- (I-Frames) and which frames are delta frames (P-frames or B-frames). moshy
60
- cannot tell the difference between a P-frame or a B-frame, so you will want
61
- to use avidemux or another program if you need to know.
62
-
63
- Run moshy with mode -m <mode> --help to see options for individual modes.
64
- "
65
- end
66
-
67
- begin
68
- opts.parse
69
- rescue OptionParser::InvalidOption, OptionParser::InvalidArgument
70
- end
71
-
72
- puts opts
73
- end
74
- end
75
-
76
- # Because we have multiple modes, we do some initial basic arg checking
77
- # to see if they specified a mode. If not, we show the top-level help menu.
78
- result = Slop.parse suppress_errors: true do |o|
79
- o.string '-m', '--mode'
80
- end
81
-
82
- mode_classes = {
83
- "inspect" => Moshy::Inspect,
84
- "isplit" => Moshy::ISplit,
85
- "pdupe" => Moshy::PDupe,
86
- "ppulse" => Moshy::PPulse,
87
- "prep" => Moshy::Prep,
88
- "bake" => Moshy::Bake
89
- }
90
-
91
- if mode_classes.has_key? result[:m]
92
- # We need to strip out the "m" otherwise our other arg parsers
93
- # will choke on the extra parameter
94
- ARGV.each_with_index do |o, i|
95
- if o == "-m" || o == "--m"
96
- ARGV.delete_at(i + 1)
97
- ARGV.delete_at(i)
98
- break
99
- end
100
- end
101
-
102
- mode_classes[result[:m]].new.cli ARGV
103
- else
104
- Moshy.top_level_help
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'slop'
5
+ require 'moshy'
6
+
7
+ module Moshy
8
+ def self.top_level_help
9
+ $options = {
10
+
11
+ }
12
+ opts = OptionParser.new do |opts|
13
+ opts.banner = "
14
+ moshy, a Ruby utility for making it easier to datamosh AVI files. It has
15
+ multiple modes that can be run with the -m or --mode option.
16
+
17
+ MODES DETAILS
18
+ -------------
19
+
20
+ \"prep\"
21
+ ------
22
+ Preps a video file for datamoshing with moshy by converting it
23
+ into an AVI with no B-Frames (they're not good for moshing), and placing as
24
+ few I-Frames as possible. Requires ffmpeg be installed locally.
25
+
26
+ \"isplit\"
27
+ --------
28
+ Extracts individual clips from an AVI where each clip is
29
+ separated by I-frames in the original AVI. Great for getting specific
30
+ clips out of a larger video and later doing I-frame moshing.
31
+
32
+ \"pdupe\"
33
+ -------
34
+ Duplicates a P-frame at a given frame a certain amount. To find
35
+ out which frames are P-frames, use software like avidemux to look at the
36
+ frame type. WARNING: This mode is a little glitchy. You may need to set
37
+ the interval 1 or 2 above or below the frame number you actually want to
38
+ duplicate. I'm not sure why this happens, but try it with a small
39
+ duplication amount first. NOTE: This can mode take a while to process
40
+ over 60-90 frame dupes.
41
+
42
+ \"ppulse\"
43
+ --------
44
+ Takes c number of frames and every n frames and duplicates them a
45
+ given amount, resulting in a consistent P-duplication datamosh that's
46
+ good for creating rhythmic effects. This was originally created to
47
+ create mosh effects in sync with a beat for a music video.
48
+
49
+ \"bake\"
50
+ ------
51
+ \"Bakes\" your datamosh by creating a new video file from your
52
+ datamoshed .avi, causing the datamosh effects to be treated as the actual
53
+ content of the new video instead of an error. Requires ffmpeg to be
54
+ installed locally.
55
+
56
+ \"inspect\"
57
+ ---------
58
+ Reads an .avi file and prints which video frames are keyframes
59
+ (I-Frames) and which frames are delta frames (P-frames or B-frames). moshy
60
+ cannot tell the difference between a P-frame or a B-frame, so you will want
61
+ to use avidemux or another program if you need to know.
62
+
63
+ Run moshy with mode -m <mode> --help to see options for individual modes.
64
+ "
65
+ end
66
+
67
+ begin
68
+ opts.parse
69
+ rescue OptionParser::InvalidOption, OptionParser::InvalidArgument
70
+ end
71
+
72
+ puts opts
73
+ end
74
+ end
75
+
76
+ # Because we have multiple modes, we do some initial basic arg checking
77
+ # to see if they specified a mode. If not, we show the top-level help menu.
78
+ result = Slop.parse suppress_errors: true do |o|
79
+ o.string '-m', '--mode'
80
+ end
81
+
82
+ puts result
83
+
84
+ mode_classes = {
85
+ "inspect" => Moshy::Inspect,
86
+ "isplit" => Moshy::ISplit,
87
+ "pdupe" => Moshy::PDupe,
88
+ "ppulse" => Moshy::PPulse,
89
+ "prep" => Moshy::Prep,
90
+ "bake" => Moshy::Bake
91
+ }
92
+
93
+ if mode_classes.has_key? result[:m]
94
+ # We need to strip out the "m" otherwise our other arg parsers
95
+ # will choke on the extra parameter
96
+ ARGV.each_with_index do |o, i|
97
+ if o == "-m" || o == "--m"
98
+ ARGV.delete_at(i + 1)
99
+ ARGV.delete_at(i)
100
+ break
101
+ end
102
+ end
103
+
104
+ mode_classes[result[:m]].new.cli ARGV
105
+ else
106
+ Moshy.top_level_help
105
107
  end