bin/command-config-generator in sfn-3.0.32 vs bin/command-config-generator in sfn-3.1.0

- old
+ new

@@ -1,44 +1,64 @@ #!/usr/bin/env ruby -require 'sfn' +require "sfn" -print 'Generating command and configuration page...' +print "Generating command and configuration page..." klasses = Sfn::Config.constants.sort.map do |const| klass = Sfn::Config.const_get(const) klass if klass.is_a?(Class) && klass.respond_to?(:attributes) end.compact -file = File.open(File.join(File.dirname(__FILE__), '..', 'docs', 'command-config.md'), 'w') +file = File.open(File.join(File.dirname(__FILE__), "..", "docs", "command-config.md"), "w") file.puts <<-EOS --- -title: "Commands and configuration" +title: "Configuration" weight: 6 anchors: EOS klasses.each do |klass| - file.puts " - title: \"#{klass.name.split('::').last} Command\"" - file.puts " url: \"##{klass.name.split('::').last.downcase}-command\"" + file.puts " - title: \"#{klass.name.split("::").last} Command\"" + file.puts " url: \"##{klass.name.split("::").last.downcase}-command\"" end -file.puts '---' +file.puts "---" +file.puts <<-EOS +# Command configurations + +This lists commands and the options which the commands accept. It also +includes the valid types which the options will accept. Options can be +set with the `.sfn` configuration file to apply default values which +can be overridden on the CLI. Options defined within the `.sfn` configuration +file are the option name with `-` characters replaced with `_`. + +For example, the option `--apply-mapping` can be defined in the `.sfn` +configuration file as: + +~~~ruby +Configuration.new do + apply_mapping true +end +~~~ + +EOS + klasses.each do |klass| - file.puts "## #{klass.name.split('::').last} Command" + file.puts "## #{klass.name.split("::").last} Command" file.puts - file.puts '~~~' - file.puts "$ sfn #{klass.name.split('::').last.downcase}" - file.puts '~~~' + file.puts "~~~" + file.puts "$ sfn #{klass.name.split("::").last.downcase}" + file.puts "~~~" file.puts "\n" file.puts "| Option | Attribute | Value" file.puts "|--------|-----------|------" klass.attributes.sort_by(&:first).map do |name, value| - file.puts "| `--#{name.to_s.tr('_', '-')}` | Description | #{value[:description]} |" - file.puts "| | Valid | `#{[value[:type]].flatten.compact.join('`, `')}` |" + file.puts "| `--#{name.to_s.tr("_", "-")}` | Description | #{value[:description]} |" + file.puts "| | Valid | `#{[value[:type]].flatten.compact.join("`, `")}` |" file.puts "| | Default | #{value[:default].inspect unless value[:default].nil?}|\n" end file.puts end -puts 'done' +puts "done"