wojtekmach-cli 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/.gitignore +3 -0
  2. data/Rakefile +18 -0
  3. data/VERSION +1 -0
  4. data/examples/rcat +20 -0
  5. data/lib/cli.rb +29 -0
  6. metadata +68 -0
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.sw*
2
+ pkg/
3
+ *.gemspec
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gemspec|
7
+ gemspec.name = "wojtekmach-cli"
8
+ gemspec.summary = "Create simple CLI apps"
9
+ gemspec.description = "Create simple CLI apps"
10
+ gemspec.email = "wojtekmach1@gmail.com"
11
+ gemspec.authors = ["Wojtek Mach"]
12
+ end
13
+ Jeweler::GemcutterTasks.new
14
+ rescue LoadError
15
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
16
+ end
17
+
18
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/examples/rcat ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.dirname(__FILE__) + "/../lib"
3
+
4
+ require 'cli'
5
+
6
+ CLI.app do
7
+ name "rcat"
8
+ version "0.0.1"
9
+
10
+ options do
11
+ opts.on("-h", "--help") do
12
+ puts "rcat 0.0.1. See cat(1)"
13
+ exit
14
+ end
15
+ end
16
+
17
+ run do
18
+ puts ARGF.read
19
+ end
20
+ end
data/lib/cli.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'optparse'
2
+
3
+ module CLI
4
+ def self.app(&block)
5
+ App.new(ARGV, &block)
6
+ end
7
+
8
+ class App
9
+ attr_reader :argv, :opts
10
+
11
+ def initialize(argv, &block)
12
+ @argv = argv
13
+ instance_eval(&block)
14
+ end
15
+
16
+ def options(&block)
17
+ @opts = OptionParser.new
18
+ instance_eval(&block)
19
+ @opts.parse!
20
+ end
21
+
22
+ def run(&block)
23
+ instance_eval(&block)
24
+ end
25
+
26
+ def name(value) @name = value end
27
+ def version(value) @version = value end
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wojtekmach-cli
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Wojtek Mach
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-09-15 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Create simple CLI apps
22
+ email: wojtekmach1@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - .gitignore
31
+ - Rakefile
32
+ - VERSION
33
+ - examples/rcat
34
+ - lib/cli.rb
35
+ has_rdoc: true
36
+ homepage:
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --charset=UTF-8
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ segments:
50
+ - 0
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.3.7
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Create simple CLI apps
67
+ test_files: []
68
+