lib/bolt/outputter/human.rb
# Print information about a task.
#
# @param task [Bolt::Task] The task information.
#
Print information about a task.
Print information about a task .
def print_task_info(task:)
        params = (task.parameters || []).sort
        info = +''
        info << colorize(:cyan, "#{task.name}\n")
        info << if task.description
                  indent(2, task.description.chomp)
                else
                  indent(2, 'No description available.')
                end
        info << "\n\n"
        usage = +''
        usage << if Bolt::Util.powershell?
                   "Invoke-BoltTask -Name #{task.name} -Targets <targets>"
                 else
                   "bolt task run #{task.name} --targets <targets>"
                 end
        usage << (Bolt::Util.powershell? ? ' [-Noop]' : ' [--noop]') if task.supports_noop
        params.each do |name, data|
          usage << if data['type']&.start_with?('Optional')
                     " [#{name}=<value>]"
                   else
                     " #{name}=<value>"
                   end
        end
        info << colorize(:cyan, "Usage\n")
        info << indent(2, wrap(usage))
        info << "\n"
        if params.any?
          info << colorize(:cyan, "Parameters\n")
          params.each do |name, data|
            info << indent(2, "#{colorize(:yellow, name)}  #{colorize(:dim, data['type'] || 'Any')}\n")
            info << indent(4, "#{wrap(data['description']).chomp}\n") if data['description']
            info << indent(4, "Default: #{data['default'].inspect}\n") if data.key?('default')
            info << "\n"
          end
        end
        path = task.files.first['path'].chomp("/tasks/#{task.files.first['name']}")
        info << colorize(:cyan, "Module\n")
        info << if path.start_with?(Bolt::Config::Modulepath::MODULES_PATH)
                  indent(2, 'built-in module')
                else
                  indent(2, path)
                end
        @stream.puts info
      end
def print_task_info ( task : ) params = ( task . parameters || [ ] ) . sort info = + '' info << colorize ( :cyan , "#{task.name}\n" ) info << if task . description indent ( 2 , task . description . chomp ) else indent ( 2 , 'No description available.' ) end info << "\n\n" usage = + '' usage << if Bolt :: Util . powershell? "Invoke-BoltTask -Name #{task.name} -Targets <targets>" else "bolt task run #{task.name} --targets <targets>" end usage << ( Bolt :: Util . powershell? ? ' [-Noop]' : ' [--noop]' ) if task . supports_noop params . each do | name , data | usage << if data [ 'type' ] &. start_with? ( 'Optional' ) " [#{name}=<value>]" else " #{name}=<value>" end end info << colorize ( :cyan , "Usage\n" ) info << indent ( 2 , wrap ( usage ) ) info << "\n" if params . any? info << colorize ( :cyan , "Parameters\n" ) params . each do | name , data | info << indent ( 2 , "#{colorize(:yellow, name)}  #{colorize(:dim, data['type'] || 'Any')}\n" ) info << indent ( 4 , "#{wrap(data['description']).chomp}\n" ) if data [ 'description' ] info << indent ( 4 , "Default: #{data['default'].inspect}\n" ) if data . key? ( 'default' ) info << "\n" end end path = task . files . first [ 'path' ] . chomp ( "/tasks/#{task.files.first['name']}" ) info << colorize ( :cyan , "Module\n" ) info << if path . start_with? ( Bolt :: Config :: Modulepath :: MODULES_PATH ) indent ( 2 , 'built-in module' ) else indent ( 2 , path ) end @stream . puts info end
Print information about a task.
Print information about a task .
# Add task name and description # Build usage string # Add usage # Add parameters, if any # Add module location
task
The task information.
The task information .