Skip to content

Commit

Permalink
Change command template to only show two commented out examples of TT…
Browse files Browse the repository at this point in the history
…Y components usage
  • Loading branch information
piotrmurach committed Sep 29, 2020
1 parent e2f57a7 commit 983ced3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 284 deletions.
108 changes: 12 additions & 96 deletions lib/tty/templates/new/lib/newcli/command.rb.tt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
# frozen_string_literal: true

require 'forwardable'

<%- constantinized_parts.each_with_index do |const, i| -%>
<%= ' ' * i %>module <%= const %>
<%= " " * i %>module <%= const %>
<%- end -%>
<%= indent %>class Command
<%= indent %> extend Forwardable

<%= indent %> def_delegators :command, :run

<%= indent %> # Execute this command
<%= indent %> #
<%= indent %> # @api public
Expand All @@ -20,105 +14,27 @@ require 'forwardable'
<%= indent %> )
<%= indent %> end

<%= indent %> # Below are examples of how to integrate TTY components

<%= indent %> # The external commands runner
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-command
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def command(**options)
<%= indent %> require 'tty-command'
<%= indent %> TTY::Command.new(options)
<%= indent %> end

<%= indent %> # The cursor movement
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-cursor
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def cursor
<%= indent %> require 'tty-cursor'
<%= indent %> TTY::Cursor
<%= indent %> end

<%= indent %> # Open a file or text in the user's preferred editor
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-editor
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def editor
<%= indent %> require 'tty-editor'
<%= indent %> TTY::Editor
<%= indent %> end

<%= indent %> # File manipulation utility methods
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-file
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def generator
<%= indent %> require 'tty-file'
<%= indent %> TTY::File
<%= indent %> end

<%= indent %> # Terminal output paging
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-pager
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def pager(**options)
<%= indent %> require 'tty-pager'
<%= indent %> TTY::Pager.new(options)
<%= indent %> end

<%= indent %> # Terminal platform and OS properties
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-platform
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def platform
<%= indent %> require 'tty-platform'
<%= indent %> TTY::Platform.new
<%= indent %> end
<%= indent %> # def command(**options)
<%= indent %> # require "tty-command"
<%= indent %> # TTY::Command.new(options)
<%= indent %> # end

<%= indent %> # The interactive prompt
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-prompt
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def prompt(**options)
<%= indent %> require 'tty-prompt'
<%= indent %> TTY::Prompt.new(options)
<%= indent %> end

<%= indent %> # Get terminal screen properties
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-screen
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def screen
<%= indent %> require 'tty-screen'
<%= indent %> TTY::Screen
<%= indent %> end

<%= indent %> # The unix which utility
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-which
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def which(*args)
<%= indent %> require 'tty-which'
<%= indent %> TTY::Which.which(*args)
<%= indent %> end

<%= indent %> # Check if executable exists
<%= indent %> #
<%= indent %> # @see http://www.rubydoc.info/gems/tty-which
<%= indent %> #
<%= indent %> # @api public
<%= indent %> def exec_exist?(*args)
<%= indent %> require 'tty-which'
<%= indent %> TTY::Which.exist?(*args)
<%= indent %> end
<%= indent %> # def prompt(**options)
<%= indent %> # require "tty-prompt"
<%= indent %> # TTY::Prompt.new(options)
<%= indent %> # end
<%- (constantinized_parts.size).downto(0) do |i| -%>
<%= ' ' * i %>end
<%= " " * i %>end
<%- end -%>
104 changes: 10 additions & 94 deletions spec/integration/new_namespaced_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,9 @@ def version
expect(::File.read("lib/cli/app/command.rb")).to eq(<<-EOS)
# frozen_string_literal: true
require 'forwardable'
module Cli
module App
class Command
extend Forwardable
def_delegators :command, :run
# Execute this command
#
# @api public
Expand All @@ -127,105 +121,27 @@ def execute(*)
)
end
# Below are examples of how to integrate TTY components
# The external commands runner
#
# @see http://www.rubydoc.info/gems/tty-command
#
# @api public
def command(**options)
require 'tty-command'
TTY::Command.new(options)
end
# The cursor movement
#
# @see http://www.rubydoc.info/gems/tty-cursor
#
# @api public
def cursor
require 'tty-cursor'
TTY::Cursor
end
# Open a file or text in the user's preferred editor
#
# @see http://www.rubydoc.info/gems/tty-editor
#
# @api public
def editor
require 'tty-editor'
TTY::Editor
end
# File manipulation utility methods
#
# @see http://www.rubydoc.info/gems/tty-file
#
# @api public
def generator
require 'tty-file'
TTY::File
end
# Terminal output paging
#
# @see http://www.rubydoc.info/gems/tty-pager
#
# @api public
def pager(**options)
require 'tty-pager'
TTY::Pager.new(options)
end
# Terminal platform and OS properties
#
# @see http://www.rubydoc.info/gems/tty-platform
#
# @api public
def platform
require 'tty-platform'
TTY::Platform.new
end
# def command(**options)
# require "tty-command"
# TTY::Command.new(options)
# end
# The interactive prompt
#
# @see http://www.rubydoc.info/gems/tty-prompt
#
# @api public
def prompt(**options)
require 'tty-prompt'
TTY::Prompt.new(options)
end
# Get terminal screen properties
#
# @see http://www.rubydoc.info/gems/tty-screen
#
# @api public
def screen
require 'tty-screen'
TTY::Screen
end
# The unix which utility
#
# @see http://www.rubydoc.info/gems/tty-which
#
# @api public
def which(*args)
require 'tty-which'
TTY::Which.which(*args)
end
# Check if executable exists
#
# @see http://www.rubydoc.info/gems/tty-which
#
# @api public
def exec_exist?(*args)
require 'tty-which'
TTY::Which.exist?(*args)
end
# def prompt(**options)
# require "tty-prompt"
# TTY::Prompt.new(options)
# end
end
end
end
Expand Down
104 changes: 10 additions & 94 deletions spec/integration/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,8 @@ def version
expect(::File.read("lib/newcli/command.rb")).to eq(<<-EOS)
# frozen_string_literal: true
require 'forwardable'
module Newcli
class Command
extend Forwardable
def_delegators :command, :run
# Execute this command
#
# @api public
Expand All @@ -203,105 +197,27 @@ def execute(*)
)
end
# Below are examples of how to integrate TTY components
# The external commands runner
#
# @see http://www.rubydoc.info/gems/tty-command
#
# @api public
def command(**options)
require 'tty-command'
TTY::Command.new(options)
end
# The cursor movement
#
# @see http://www.rubydoc.info/gems/tty-cursor
#
# @api public
def cursor
require 'tty-cursor'
TTY::Cursor
end
# Open a file or text in the user's preferred editor
#
# @see http://www.rubydoc.info/gems/tty-editor
#
# @api public
def editor
require 'tty-editor'
TTY::Editor
end
# File manipulation utility methods
#
# @see http://www.rubydoc.info/gems/tty-file
#
# @api public
def generator
require 'tty-file'
TTY::File
end
# Terminal output paging
#
# @see http://www.rubydoc.info/gems/tty-pager
#
# @api public
def pager(**options)
require 'tty-pager'
TTY::Pager.new(options)
end
# Terminal platform and OS properties
#
# @see http://www.rubydoc.info/gems/tty-platform
#
# @api public
def platform
require 'tty-platform'
TTY::Platform.new
end
# def command(**options)
# require "tty-command"
# TTY::Command.new(options)
# end
# The interactive prompt
#
# @see http://www.rubydoc.info/gems/tty-prompt
#
# @api public
def prompt(**options)
require 'tty-prompt'
TTY::Prompt.new(options)
end
# Get terminal screen properties
#
# @see http://www.rubydoc.info/gems/tty-screen
#
# @api public
def screen
require 'tty-screen'
TTY::Screen
end
# The unix which utility
#
# @see http://www.rubydoc.info/gems/tty-which
#
# @api public
def which(*args)
require 'tty-which'
TTY::Which.which(*args)
end
# Check if executable exists
#
# @see http://www.rubydoc.info/gems/tty-which
#
# @api public
def exec_exist?(*args)
require 'tty-which'
TTY::Which.exist?(*args)
end
# def prompt(**options)
# require "tty-prompt"
# TTY::Prompt.new(options)
# end
end
end
EOS
Expand Down

0 comments on commit 983ced3

Please sign in to comment.