135: def initialize( cmdparser )
136: super( 'use', true )
137: self.short_desc = "Changes the used website or gallery styles"
138:
139: @force = false
140: self.options = CmdParse::OptionParserWrapper.new do |opts|
141: opts.separator "Options:"
142: opts.on( '-f', '--[no-]force', 'If specified, existing files are overwritten without asking.' ) {|@force|}
143: end
144:
145:
146: useWebsiteStyle = CmdParse::Command.new( 'website_style', false )
147: useWebsiteStyle.short_desc = "Changes the used website style"
148: useWebsiteStyle.description =
149: CliUtils.format("\nCopies the style files for the website style STYLE to the website " +
150: "directory defined by the global directory option, overwritting existing " +
151: "files. If the global verbosity level is set to 0 or 1, the copied files are listed.")
152: useWebsiteStyle.options = CmdParse::OptionParserWrapper.new do |opts|
153: opts.separator "Available styles:"
154: opts.separator ""
155: Webgen::WebSiteStyle.entries.sort.each {|name, entry| CliUtils.dirinfo_output( opts, name, entry ) }
156: end
157: def useWebsiteStyle.usage
158: "Usage: #{commandparser.program_name} [global options] use website_style STYLE"
159: end
160: useWebsiteStyle.set_execution_block do |args|
161: if args.length == 0
162: raise OptionParser::MissingArgument.new( 'STYLE' )
163: else
164: if @force || ask_overwrite
165: files = Webgen::WebSite.use_website_style( cmdparser.directory, args[0] )
166: if (0..1) === cmdparser.verbosity
167: puts "The following files were created or overwritten:"
168: puts files.collect {|f| "- " + f }.join("\n")
169: end
170: end
171: end
172: end
173: self.add_command( useWebsiteStyle )
174:
175:
176: useGalleryStyle = CmdParse::Command.new( 'gallery_style', false )
177: useGalleryStyle.short_desc = "Changes the used gallery style"
178: useGalleryStyle.description =
179: CliUtils.format("\nCopies the gallery templates for the gallery style STYLE to the website " +
180: "directory defined by the global directory option, overwritting existing files. " +
181: "If the global verbosity level is set to 0 or 1, the copied files are listed.")
182: useGalleryStyle.options = CmdParse::OptionParserWrapper.new do |opts|
183: opts.separator "Available styles:"
184: opts.separator ""
185: Webgen::GalleryStyle.entries.sort.each {|name, entry| CliUtils.dirinfo_output( opts, name, entry ) }
186: end
187: def useGalleryStyle.usage
188: "Usage: #{commandparser.program_name} [global options] use gallery_style STYLE"
189: end
190: useGalleryStyle.set_execution_block do |args|
191: if args.length == 0
192: raise OptionParser::MissingArgument.new( 'STYLE' )
193: else
194: if @force || ask_overwrite
195: files = Webgen::WebSite.use_gallery_style( cmdparser.directory, args[0] )
196: if (0..1) === cmdparser.verbosity
197: puts "The following files were created or overwritten:"
198: puts files.collect {|f| "- " + f }.join("\n")
199: end
200: end
201: end
202: end
203: self.add_command( useGalleryStyle )
204:
205:
206: useSipttraStyle = CmdParse::Command.new( 'sipttra_style', false )
207: useSipttraStyle.short_desc = "Changes the used sipttra style"
208: useSipttraStyle.description =
209: CliUtils.format("\nCopies the sipttra styles files for the sipttra style STYLE to the website " +
210: "directory defined by the global directory option, overwritting existing files. " +
211: "If the global verbosity level is set to 0 or 1, the copied files are listed.")
212: useSipttraStyle.options = CmdParse::OptionParserWrapper.new do |opts|
213: opts.separator "Available styles:"
214: opts.separator ""
215: Webgen::SipttraStyle.entries.sort.each {|name, entry| CliUtils.dirinfo_output( opts, name, entry ) }
216: end
217: def useSipttraStyle.usage
218: "Usage: #{commandparser.program_name} [global options] use sipttra_style STYLE"
219: end
220: useSipttraStyle.set_execution_block do |args|
221: if args.length == 0
222: raise OptionParser::MissingArgument.new( 'STYLE' )
223: else
224: if @force || ask_overwrite
225: files = Webgen::WebSite.use_sipttra_style( cmdparser.directory, args[0] )
226: if (0..1) === cmdparser.verbosity
227: puts "The following files were created or overwritten:"
228: puts files.collect {|f| "- " + f }.join("\n")
229: end
230: end
231: end
232: end
233: self.add_command( useSipttraStyle )
234: end