cli-template 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17cbbe8fe23b402c5d7186db07b36efb7558de259644e26b16bdcec71aef8e2d
4
- data.tar.gz: 4786c899d4991565425a177028c0392af5d99d89578ebe16266f8b9d21eeb0a9
3
+ metadata.gz: 27407ac819b71368058edec6400c5489610b7446622c3636a423c49068da6fdf
4
+ data.tar.gz: ca8952b2291e00868fb233d611ad51970cf5964df8aba0e4f9e2cef11eff611f
5
5
  SHA512:
6
- metadata.gz: 62acac1019b70985dbcc86c45249ecd8d7ead6730780b8b90379981ae2a244c1716d3c93eb1fb6f23d5bc8057517fc7d4062548b5be633427794636ab61c0f59
7
- data.tar.gz: 0a9b85c698aabcde90a88f8b47cb400dfee8ced3761d926ea7201752a287e487cf99630af0fd544bd8037e3cb4f49c4663b95897508bd86560b21b4865822d1e
6
+ metadata.gz: 32911657ed62c3ceb799f2103f22d8fa62d0a85d94e8d1fe57a6ab25a94eed31a2369284a7e457b45546c77e0829d7528047ad62707147815cac15a8ed6073e3
7
+ data.tar.gz: e80cebb0c4e8b0c727ef6c0adf8e44045fd2ea84240e0b1a4ee6ecb217e61826bdc5987d42524fb7acc02aae89d2f6b0c171961ae32f288e9c13468844993c92
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [3.4.0]
7
+ - add class Error in generated class
8
+ - add cli_markdown and rake docs task
9
+ - add possible website url reference to cli help
10
+ - change help also available at
11
+ - move common commands to base Command class
12
+ - move version, completion commands back to the CLI class so subcommands dont inherit them
13
+ - override command_help to include description in long_description
14
+ - remove unused completion.rb, fix command_help override
15
+ - use 4 spaces for cli help
16
+
6
17
  ## [3.3.0]
7
18
  - fix completer for thor group and use public_instance_methods(false)
8
19
  - fix shared new options for thor group and cli
@@ -1,4 +1,4 @@
1
1
  Examples:
2
2
 
3
- cli-template new hello
4
- cli-template new another_project
3
+ cli-template new hello
4
+ cli-template new another_project
@@ -27,7 +27,6 @@ module CliTemplate
27
27
  end
28
28
 
29
29
  def make_executable
30
- chmod("bin", 0755 & ~File.umask, verbose: false) if File.exist?("bin")
31
30
  chmod("exe", 0755 & ~File.umask, verbose: false) if File.exist?("exe")
32
31
  end
33
32
 
@@ -55,6 +54,7 @@ Congrats 🎉 You have successfully created a CLI project.
55
54
  Test the CLI:
56
55
 
57
56
  cd #{project_name}
57
+ bundle
58
58
  exe/#{project_name} hello # top-level commands
59
59
  exe/#{project_name} sub:goodbye # sub commands
60
60
  bundle exec rspec
@@ -1,3 +1,3 @@
1
1
  module CliTemplate
2
- VERSION = "3.3.0"
2
+ VERSION = "3.4.0"
3
3
  end
@@ -1,7 +1,5 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "<%= underscored_name %>/version"
1
+ # -*- encoding: utf-8 -*-
2
+ require_relative "lib/<%= underscored_name %>/version"
5
3
 
6
4
  Gem::Specification.new do |spec|
7
5
  spec.name = "<%= project_name %>"
@@ -1,6 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
 
4
- task :default => :spec
4
+ task default: :spec
5
5
 
6
6
  RSpec::Core::RakeTask.new
@@ -7,8 +7,5 @@ Signal.trap("INT") {
7
7
  exit
8
8
  }
9
9
 
10
- $:.unshift(File.expand_path("../../lib", __FILE__))
11
- require "<%= project_name %>"
12
- require "<%= underscored_name %>/cli"
13
-
14
- <%= project_class_name %>::CLI.start(ARGV)
10
+ require_relative "../lib/<%= project_name %>"
11
+ <%= project_class_name %>::CLI.start
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["tongueroo@gmail.com"]
11
11
  spec.summary = "Generated with cli-template tool. Please write a gem summary"
12
12
  spec.description = "Generated with cli-template tool. Write a longer description or delete this line."
13
- spec.homepage = "Generated with cli-template tool. Put your gem's website or public repo URL here."
13
+ spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -19,12 +19,13 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "thor"
23
- spec.add_dependency "colorize"
24
- spec.add_dependency "rake"
25
22
  spec.add_dependency "activesupport"
23
+ spec.add_dependency "colorize"
24
+ spec.add_dependency "thor"
26
25
 
27
26
  spec.add_development_dependency "bundler"
28
27
  spec.add_development_dependency "byebug"
28
+ spec.add_development_dependency "cli_markdown"
29
+ spec.add_development_dependency "rake"
29
30
  spec.add_development_dependency "rspec"
30
31
  end
@@ -11,10 +11,8 @@ TODO: Write a gem description
11
11
 
12
12
  ## Usage
13
13
 
14
- ```sh
15
- <%= project_name %> hello yourname
16
- <%= project_name %> sub:goodbye yourname
17
- ```
14
+ <%= project_name %> hello yourname
15
+ <%= project_name %> sub:goodbye yourname
18
16
 
19
17
  The CLI tool also detects and tasks in the current folder's Rakefile and delegate to those tasks.
20
18
 
@@ -22,21 +20,15 @@ The CLI tool also detects and tasks in the current folder's Rakefile and delegat
22
20
 
23
21
  Add this line to your application's Gemfile:
24
22
 
25
- ```sh
26
- gem "<%= project_name %>"
27
- ```
23
+ gem "<%= project_name %>"
28
24
 
29
25
  And then execute:
30
26
 
31
- ```sh
32
- bundle
33
- ```
27
+ bundle
34
28
 
35
29
  Or install it yourself as:
36
30
 
37
- ```sh
38
- gem install <%= project_name %>
39
- ```
31
+ gem install <%= project_name %>
40
32
 
41
33
  ## Contributing
42
34
 
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ task default: :spec
5
+
6
+ RSpec::Core::RakeTask.new
7
+
8
+ require_relative "lib/<%= project_name %>"
9
+ require "cli_markdown"
10
+ desc "Generates cli reference docs as markdown"
11
+ task :docs do
12
+ CliMarkdown::Creator.create_all(cli_class: <%= project_class_name %>::CLI, cli_name: "<%= project_name %>")
13
+ end
@@ -2,10 +2,12 @@ $:.unshift(File.expand_path("../", __FILE__))
2
2
  require "<%= underscored_name %>/version"
3
3
 
4
4
  module <%= project_class_name %>
5
- autoload :Help, "<%= underscored_name %>/help"
6
- autoload :Command, "<%= underscored_name %>/command"
5
+ class Error < StandardError; end
6
+
7
7
  autoload :CLI, "<%= underscored_name %>/cli"
8
- autoload :Sub, "<%= underscored_name %>/sub"
9
- autoload :Completion, "<%= underscored_name %>/completion"
8
+ autoload :Command, "<%= underscored_name %>/command"
10
9
  autoload :Completer, "<%= underscored_name %>/completer"
10
+ autoload :Completion, "<%= underscored_name %>/completion"
11
+ autoload :Help, "<%= underscored_name %>/help"
12
+ autoload :Sub, "<%= underscored_name %>/sub"
11
13
  end
@@ -3,7 +3,7 @@ module <%= project_class_name %>
3
3
  class_option :verbose, type: :boolean
4
4
  class_option :noop, type: :boolean
5
5
 
6
- desc "hello NAME", "say hello to NAME"
6
+ desc "hello NAME", "Say hello to NAME."
7
7
  long_desc Help.text(:hello)
8
8
  option :from, desc: "from person"
9
9
  def hello(name="you")
@@ -15,13 +15,13 @@ module <%= project_class_name %>
15
15
  long_desc Help.text(:sub)
16
16
  subcommand "sub", Sub
17
17
 
18
- desc "completion *PARAMS", "prints words for auto-completion"
18
+ desc "completion *PARAMS", "Prints words for auto-completion."
19
19
  long_desc Help.text("completion")
20
20
  def completion(*params)
21
21
  Completer.new(CLI, *params).run
22
22
  end
23
23
 
24
- desc "completion_script", "generates script that can be eval to setup auto-completion", hide: true
24
+ desc "completion_script", "Generates a script that can be eval to setup auto-completion."
25
25
  long_desc Help.text("completion_script")
26
26
  def completion_script
27
27
  Completer::Script.generate
@@ -42,6 +42,41 @@ module <%= project_class_name %>
42
42
 
43
43
  super
44
44
  end
45
+
46
+ # Override command_help to include the description at the top of the
47
+ # long_description.
48
+ def command_help(shell, command_name)
49
+ meth = normalize_command_name(command_name)
50
+ command = all_commands[meth]
51
+ alter_command_description(command)
52
+ super
53
+ end
54
+
55
+ def alter_command_description(command)
56
+ return unless command
57
+
58
+ # Add description to beginning of long_description
59
+ long_desc = if command.long_description
60
+ "#{command.description}\n\n#{command.long_description}"
61
+ else
62
+ command.description
63
+ end
64
+
65
+ # add reference url to end of the long_description
66
+ unless website.empty?
67
+ full_command = [command.ancestor_name, command.name].compact.join('-')
68
+ url = "#{website}/reference/<%= project_name %>-#{full_command}"
69
+ long_desc += "\n\nHelp also available at: #{url}"
70
+ end
71
+
72
+ command.long_description = long_desc
73
+ end
74
+ private :alter_command_description
75
+
76
+ # meant to be overriden
77
+ def website
78
+ ""
79
+ end
45
80
  end
46
81
  end
47
82
  end
@@ -68,7 +68,7 @@ Sometimes the commands are not simple thor commands but are subcommands or Thor:
68
68
 
69
69
  Auto-completion accounts for each of these type of commands.
70
70
  =end
71
- module Ufo
71
+ module <%= project_class_name %>
72
72
  class Completer
73
73
  autoload :Script, '<%= underscored_name %>/completer/script'
74
74
 
@@ -1,22 +1,22 @@
1
1
  Example:
2
2
 
3
- <%= project_name %> completion
3
+ <%= project_name %> completion
4
4
 
5
5
  Prints words for TAB auto-completion.
6
6
 
7
7
  Examples:
8
8
 
9
- <%= project_name %> completion
10
- <%= project_name %> completion hello
11
- <%= project_name %> completion hello name
9
+ <%= project_name %> completion
10
+ <%= project_name %> completion hello
11
+ <%= project_name %> completion hello name
12
12
 
13
13
  To enable, TAB auto-completion add the following to your profile:
14
14
 
15
- eval $(<%= project_name %> completion script)
15
+ eval $(<%= project_name %> completion_script)
16
16
 
17
17
  Auto-completion example usage:
18
18
 
19
- <%= project_name %> [TAB]
20
- <%= project_name %> hello [TAB]
21
- <%= project_name %> hello name [TAB]
22
- <%= project_name %> hello name --[TAB]
19
+ <%= project_name %> [TAB]
20
+ <%= project_name %> hello [TAB]
21
+ <%= project_name %> hello name [TAB]
22
+ <%= project_name %> hello name --[TAB]
@@ -1,3 +1,3 @@
1
- To use, add the following to your ~/.bashrc or ~/.profile
1
+ To use, add the following to your `~/.bashrc` or `~/.profile`
2
2
 
3
- eval $(<%= project_name %> completion script)
3
+ eval $(<%= project_name %> completion_script)
@@ -1,5 +1,5 @@
1
1
  Examples:
2
2
 
3
- <%= project_name %> hello
4
- <%= project_name %> hello NAME
5
- <%= project_name %> hello NAME --from me
3
+ <%= project_name %> hello
4
+ <%= project_name %> hello NAME
5
+ <%= project_name %> hello NAME --from me
@@ -1,5 +1,5 @@
1
1
  Examples:
2
2
 
3
- <%= project_name %> sub:goodbye
4
- <%= project_name %> sub:goodbye NAME
5
- <%= project_name %> sub:goodbye NAME --from me
3
+ <%= project_name %> sub:goodbye
4
+ <%= project_name %> sub:goodbye NAME
5
+ <%= project_name %> sub:goodbye NAME --from me
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-14 00:00:00.000000000 Z
11
+ date: 2018-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -202,7 +202,7 @@ files:
202
202
  - lib/templates/default/Guardfile
203
203
  - lib/templates/default/LICENSE.txt
204
204
  - lib/templates/default/README.md.tt
205
- - lib/templates/default/Rakefile
205
+ - lib/templates/default/Rakefile.tt
206
206
  - lib/templates/default/exe/%project_name%.tt
207
207
  - lib/templates/default/lib/%project_name%.rb.tt
208
208
  - lib/templates/default/lib/%underscored_name%/cli.rb.tt
@@ -210,7 +210,6 @@ files:
210
210
  - lib/templates/default/lib/%underscored_name%/completer.rb.tt
211
211
  - lib/templates/default/lib/%underscored_name%/completer/script.rb.tt
212
212
  - lib/templates/default/lib/%underscored_name%/completer/script.sh.tt
213
- - lib/templates/default/lib/%underscored_name%/completion.rb.tt
214
213
  - lib/templates/default/lib/%underscored_name%/help.rb.tt
215
214
  - lib/templates/default/lib/%underscored_name%/help/completion.md.tt
216
215
  - lib/templates/default/lib/%underscored_name%/help/completion_script.md.tt
@@ -242,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
241
  version: '0'
243
242
  requirements: []
244
243
  rubyforge_project:
245
- rubygems_version: 2.7.3
244
+ rubygems_version: 2.7.6
246
245
  signing_key:
247
246
  specification_version: 4
248
247
  summary: Generate a CLI tool quickly
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- task :default => :spec
5
-
6
- RSpec::Core::RakeTask.new
@@ -1,15 +0,0 @@
1
- module <%= project_class_name %>
2
- class Completion < Command
3
- desc "script", "generates script that can be eval to setup auto-completion"
4
- long_desc Help.text("completion:script")
5
- def script
6
- Completer::Script.generate
7
- end
8
-
9
- desc "completions *PARAMS", "prints words for auto-completion"
10
- long_desc Help.text("completion:list")
11
- def list(*params)
12
- Completer.new(*params).run
13
- end
14
- end
15
- end