mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
Generate man page using ronn
This commit is contained in:
parent
ecb532ea87
commit
1b587d8257
5 changed files with 225 additions and 4 deletions
27
Rakefile
27
Rakefile
|
@ -10,4 +10,31 @@ RuboCop::RakeTask.new do |task|
|
||||||
task.requires << 'rubocop-rspec'
|
task.requires << 'rubocop-rspec'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc 'Build the manual'
|
||||||
|
file 'man/colorls.1' => ['man/colorls.1.ronn', 'lib/colorls/flags.rb'] do
|
||||||
|
require 'colorls'
|
||||||
|
require 'ronn'
|
||||||
|
|
||||||
|
flags = ColorLS::Flags.new
|
||||||
|
attributes = {
|
||||||
|
date: Time.now,
|
||||||
|
manual: 'colorls Manual',
|
||||||
|
organization: "colorls #{ColorLS::VERSION}"
|
||||||
|
}
|
||||||
|
doc = Ronn::Document.new(nil, attributes) do
|
||||||
|
template = IO.read('man/colorls.1.ronn')
|
||||||
|
|
||||||
|
section = ''
|
||||||
|
flags.options.each do |o|
|
||||||
|
section += <<OPTION
|
||||||
|
* `#{o.flags.join('`, `')}`:
|
||||||
|
#{o.desc.join("<br>\n")}
|
||||||
|
|
||||||
|
OPTION
|
||||||
|
end
|
||||||
|
template.sub('{{ OPTIONS }}', section)
|
||||||
|
end
|
||||||
|
IO.write('man/colorls.1', doc.convert('roff'))
|
||||||
|
end
|
||||||
|
|
||||||
task default: %w[spec rubocop]
|
task default: %w[spec rubocop]
|
||||||
|
|
|
@ -21,6 +21,7 @@ ColorLS::POST_INSTALL_MESSAGE = %(
|
||||||
*******************************************************************
|
*******************************************************************
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
|
# rubocop:disable Metrics/BlockLength
|
||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
spec.name = 'colorls'
|
spec.name = 'colorls'
|
||||||
spec.version = ColorLS::VERSION
|
spec.version = ColorLS::VERSION
|
||||||
|
@ -31,7 +32,7 @@ Gem::Specification.new do |spec|
|
||||||
spec.license = 'MIT'
|
spec.license = 'MIT'
|
||||||
|
|
||||||
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
||||||
f.match(%r{^(test|spec|features)/})
|
f.match(%r{^(test|spec|features|man)/})
|
||||||
end
|
end
|
||||||
spec.bindir = 'exe'
|
spec.bindir = 'exe'
|
||||||
spec.executables = 'colorls'
|
spec.executables = 'colorls'
|
||||||
|
@ -45,6 +46,7 @@ Gem::Specification.new do |spec|
|
||||||
spec.add_development_dependency 'bundler', '~> 1.15'
|
spec.add_development_dependency 'bundler', '~> 1.15'
|
||||||
spec.add_development_dependency 'diffy'
|
spec.add_development_dependency 'diffy'
|
||||||
spec.add_development_dependency 'rake'
|
spec.add_development_dependency 'rake'
|
||||||
|
spec.add_development_dependency 'ronn'
|
||||||
spec.add_development_dependency 'rspec'
|
spec.add_development_dependency 'rspec'
|
||||||
spec.add_development_dependency 'rspec-its'
|
spec.add_development_dependency 'rspec-its'
|
||||||
spec.add_development_dependency 'rubocop'
|
spec.add_development_dependency 'rubocop'
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
require 'colorls/version'
|
require 'colorls/version'
|
||||||
|
require 'ostruct'
|
||||||
|
|
||||||
module ColorLS
|
module ColorLS
|
||||||
class Flags
|
class Flags
|
||||||
|
@ -42,6 +43,21 @@ module ColorLS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def options
|
||||||
|
list = @parser.top.list + @parser.base.list
|
||||||
|
|
||||||
|
result = list.collect do |o|
|
||||||
|
next unless o.respond_to? 'desc'
|
||||||
|
|
||||||
|
flags = o.short + o.long
|
||||||
|
next if flags.empty?
|
||||||
|
|
||||||
|
OpenStruct.new(flags: flags, desc: o.desc)
|
||||||
|
end
|
||||||
|
|
||||||
|
result.compact
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def add_sort_options(options)
|
def add_sort_options(options)
|
||||||
|
@ -115,7 +131,7 @@ EXAMPLES
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_options
|
def parse_options
|
||||||
parser = OptionParser.new do |opts|
|
@parser = OptionParser.new do |opts|
|
||||||
opts.banner = 'Usage: colorls [OPTION]... [FILE]...'
|
opts.banner = 'Usage: colorls [OPTION]... [FILE]...'
|
||||||
opts.separator ''
|
opts.separator ''
|
||||||
|
|
||||||
|
@ -125,7 +141,7 @@ EXAMPLES
|
||||||
|
|
||||||
opts.separator ''
|
opts.separator ''
|
||||||
opts.on_tail('-h', '--help', 'prints this help') do
|
opts.on_tail('-h', '--help', 'prints this help') do
|
||||||
puts parser
|
puts @parser
|
||||||
show_examples
|
show_examples
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
@ -135,7 +151,7 @@ EXAMPLES
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.parse!(@args)
|
@parser.parse!(@args)
|
||||||
|
|
||||||
set_color_opts
|
set_color_opts
|
||||||
end
|
end
|
||||||
|
|
135
man/colorls.1
Normal file
135
man/colorls.1
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
.\" generated with Ronn/v0.7.3
|
||||||
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||||
|
.
|
||||||
|
.TH "COLORLS" "1" "November 2017" "colorls 1.0.9" "colorls Manual"
|
||||||
|
.
|
||||||
|
.SH "NAME"
|
||||||
|
\fBcolorls\fR \- list directory contents with colors and icons
|
||||||
|
.
|
||||||
|
.SH "SYNOPSIS"
|
||||||
|
\fBcolorls\fR [OPTION]\.\.\. [FILE]\.\.\.
|
||||||
|
.
|
||||||
|
.br
|
||||||
|
.
|
||||||
|
.SH "DESCRIPTION"
|
||||||
|
List information about the given FILEs\. Uses different colors and icons for known file types\.
|
||||||
|
.
|
||||||
|
.P
|
||||||
|
By default, the output is sorted alphabetically\.
|
||||||
|
.
|
||||||
|
.P
|
||||||
|
Mandatory arguments to long options are mandatory for short options too\.
|
||||||
|
.
|
||||||
|
.SH "OPTIONS"
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-a\fR, \fB\-\-all\fR
|
||||||
|
do not ignore entries starting with \.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-A\fR, \fB\-\-almost\-all\fR
|
||||||
|
do not list \. and \.\.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-l\fR, \fB\-\-long\fR
|
||||||
|
use a long listing format
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-tree\fR
|
||||||
|
shows tree view of the directory
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-report\fR
|
||||||
|
show brief report
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-1\fR
|
||||||
|
list one file per line
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-d\fR, \fB\-\-dirs\fR
|
||||||
|
show only directories
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-f\fR, \fB\-\-files\fR
|
||||||
|
show only files
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-gs\fR, \fB\-\-git\-status\fR
|
||||||
|
show git status for each file
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-sd\fR, \fB\-\-sort\-dirs\fR, \fB\-\-group\-directories\-first\fR
|
||||||
|
sort directories first
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-sf\fR, \fB\-\-sort\-files\fR
|
||||||
|
sort files first
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-t\fR
|
||||||
|
sort by modification time, newest first
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-U\fR
|
||||||
|
do not sort; list entries in directory order
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-S\fR
|
||||||
|
sort by file size, largest first
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-sort\fR
|
||||||
|
sort by WORD instead of name: none, size (\-S), time (\-t)
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-r\fR, \fB\-\-reverse\fR
|
||||||
|
reverse order while sorting
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-light\fR
|
||||||
|
use light color scheme
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-dark\fR
|
||||||
|
use dark color scheme
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
|
prints this help
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-version\fR
|
||||||
|
show version
|
||||||
|
.
|
||||||
|
.SH "EXAMPLES"
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
show the given file:
|
||||||
|
.
|
||||||
|
.IP
|
||||||
|
\fBcolorls README\.md\fR
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
show matching files and list matching directories:
|
||||||
|
.
|
||||||
|
.IP
|
||||||
|
\fBcolorls *\fR
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
filter output by a regular expression:
|
||||||
|
.
|
||||||
|
.IP
|
||||||
|
\fBcolorls | grep PATTERN\fR
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
several short options can be combined:
|
||||||
|
.
|
||||||
|
.IP
|
||||||
|
\fBcolorls \-d \-l \-a\fR
|
||||||
|
.
|
||||||
|
.br
|
||||||
|
\fBcolorls \-dla\fR
|
||||||
|
.
|
||||||
|
.SH "AUTHOR"
|
||||||
|
Written by Athitya Kumar\.
|
41
man/colorls.1.ronn
Normal file
41
man/colorls.1.ronn
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
colorls(1) -- list directory contents with colors and icons
|
||||||
|
===========================================================
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
|
||||||
|
`colorls` [OPTION]... [FILE]...<br>
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
|
||||||
|
List information about the given FILEs. Uses different colors and icons for known file types.
|
||||||
|
|
||||||
|
By default, the output is sorted alphabetically.
|
||||||
|
|
||||||
|
Mandatory arguments to long options are mandatory for short options too.
|
||||||
|
|
||||||
|
## OPTIONS
|
||||||
|
|
||||||
|
{{ OPTIONS }}
|
||||||
|
|
||||||
|
## EXAMPLES
|
||||||
|
|
||||||
|
* show the given file:
|
||||||
|
|
||||||
|
`colorls README.md`
|
||||||
|
|
||||||
|
* show matching files and list matching directories:
|
||||||
|
|
||||||
|
`colorls *`
|
||||||
|
|
||||||
|
* filter output by a regular expression:
|
||||||
|
|
||||||
|
`colorls | grep PATTERN`
|
||||||
|
|
||||||
|
* several short options can be combined:
|
||||||
|
|
||||||
|
`colorls -d -l -a`<br>
|
||||||
|
`colorls -dla`
|
||||||
|
|
||||||
|
## AUTHOR
|
||||||
|
|
||||||
|
Written by Athitya Kumar.
|
Loading…
Reference in a new issue