Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed typo in indent word #198

Merged
merged 1 commit into from Nov 23, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/thor.rb
Expand Up @@ -164,7 +164,7 @@ def task_help(shell, task_name)
class_options_help(shell, nil => task.options.map { |_, o| o })
if task.long_description
shell.say "Description:"
shell.print_wrapped(task.long_description, :ident => 2)
shell.print_wrapped(task.long_description, :indent => 2)
else
shell.say task.description
end
Expand All @@ -183,7 +183,7 @@ def help(shell, subcommand = false)
list.sort!{ |a,b| a[0] <=> b[0] }

shell.say "Tasks:"
shell.print_table(list, :ident => 2, :truncate => true)
shell.print_table(list, :indent => 2, :truncate => true)
shell.say
class_options_help(shell)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/thor/base.rb
Expand Up @@ -476,7 +476,7 @@ def print_options(shell, options, group_name=nil)
end

shell.say(group_name ? "#{group_name} options:" : "Options:")
shell.print_table(list, :ident => 2)
shell.print_table(list, :indent => 2)
shell.say ""
end

Expand Down
14 changes: 7 additions & 7 deletions lib/thor/shell/basic.rb
Expand Up @@ -100,13 +100,13 @@ def no?(statement, color=nil)
# Array[Array[String, String, ...]]
#
# ==== Options
# ident<Integer>:: Indent the first column by ident value.
# indent<Integer>:: Indent the first column by indent value.
# colwidth<Integer>:: Force the first column to colwidth spaces wide.
#
def print_table(table, options={})
return if table.empty?

formats, ident, colwidth = [], options[:ident].to_i, options[:colwidth]
formats, indent, colwidth = [], options[:indent].to_i, options[:colwidth]
options[:truncate] = terminal_width if options[:truncate] == true

formats << "%-#{colwidth + 2}s" if colwidth
Expand All @@ -119,7 +119,7 @@ def print_table(table, options={})
formats << "%-#{maxima + 2}s"
end

formats[0] = formats[0].insert(0, " " * ident)
formats[0] = formats[0].insert(0, " " * indent)
formats << "%s"

table.each do |row|
Expand All @@ -141,11 +141,11 @@ def print_table(table, options={})
# String
#
# ==== Options
# ident<Integer>:: Indent each line of the printed paragraph by ident value.
# indent<Integer>:: Indent each line of the printed paragraph by indent value.
#
def print_wrapped(message, options={})
ident = options[:ident] || 0
width = terminal_width - ident
indent = options[:indent] || 0
width = terminal_width - indent
paras = message.split("\n\n")

paras.map! do |unwrapped|
Expand All @@ -156,7 +156,7 @@ def print_wrapped(message, options={})

paras.each do |para|
para.split("\n").each do |line|
stdout.puts line.insert(0, " " * ident)
stdout.puts line.insert(0, " " * indent)
end
stdout.puts unless para == paras.last
end
Expand Down
6 changes: 3 additions & 3 deletions spec/shell/basic_spec.rb
Expand Up @@ -122,8 +122,8 @@ def shell
TABLE
end

it "prints a table with identation" do
content = capture(:stdout){ shell.print_table(@table, :ident => 2) }
it "prints a table with indentation" do
content = capture(:stdout){ shell.print_table(@table, :indent => 2) }
content.should == <<-TABLE
abc #123 first three
#0 empty
Expand All @@ -133,7 +133,7 @@ def shell

it "uses maximum terminal width" do
shell.should_receive(:terminal_width).and_return(20)
content = capture(:stdout){ shell.print_table(@table, :ident => 2, :truncate => true) }
content = capture(:stdout){ shell.print_table(@table, :indent => 2, :truncate => true) }
content.should == <<-TABLE
abc #123 firs...
#0 empty
Expand Down