44require 'docopt'
55
66module Madness
7-
87 # Handle command line execution. Used by bin/madness.
98 class CommandLine
109 include Singleton
1110 include Colsole
1211
1312 # Process ARGV by putting it through docopt
14- def execute ( argv = [ ] )
13+ def execute ( argv = [ ] )
1514 doc = File . read File . expand_path ( 'docopt.txt' , __dir__ )
16-
15+
1716 begin
1817 args = Docopt . docopt ( doc , argv : argv , version : VERSION )
1918 handle args
@@ -49,7 +48,7 @@ def launch_server_with_options(args)
4948 # and static files folder.
5049 def launch_server
5150 unless File . directory? config . path
52- STDERR . puts "Invalid path (#{ config . path } )"
51+ $stderr . puts "Invalid path (#{ config . path } )"
5352 return
5453 end
5554
@@ -61,7 +60,7 @@ def launch_server
6160 # Get the arguments as provided by docopt, and set them to our own
6261 # config object.
6362 def set_config ( args )
64- config . path = args [ 'PATH' ] if args [ 'PATH' ]
63+ config . path = args [ 'PATH' ] if args [ 'PATH' ]
6564 config . port = args [ '--port' ] . to_i if args [ '--port' ]
6665 config . bind = args [ '--bind' ] if args [ '--bind' ]
6766 config . toc = args [ '--toc' ] if args [ '--toc' ]
@@ -76,7 +75,7 @@ def set_config(args)
7675 config . copy_code = false if args [ '--no-copy-code' ]
7776 config . shortlinks = true if args [ '--shortlinks' ]
7877 config . open = true if args [ '--open' ]
79-
78+
8079 config . theme = File . expand_path ( args [ '--theme' ] , config . path ) if args [ '--theme' ]
8180 end
8281
@@ -105,7 +104,7 @@ def create_theme(path)
105104 end
106105 end
107106
108- # Say hello to everybody when the server starts, showing the known
107+ # Say hello to everybody when the server starts, showing the known
109108 # config.
110109 def show_status
111110 say_status :start , 'the madness'
@@ -115,7 +114,7 @@ def show_status
115114 say_status :use , config . filename if config . file_exist?
116115 say_status :theme , config . theme , :txtblu if config . theme
117116
118- say "-" * 60
117+ say '-' * 60
119118 end
120119
121120 # Generate the table of contents file
0 commit comments