class Object
Public Instance Methods
init()
click to toggle source
# File bin/septober 68 def init 69 $opts[:config_file] = $opts[:dflt_config_file] 70 $optparse = OptionParser.new do |opts| 71 opts.on( '-c', '--config <FILE>', 'uses a different configfile from: '+$opts[:dflt_config_file] ) {|arg_file| 72 puts "Importing file different from default: #{yellow arg_file}" 73 $opts[:config_file] = arg_file 74 } 75 opts.on( '-d', '--debug', 'enables debug (DFLT=false)' ) { $opts[:debug] = true ; $debug = true ; debug_on('Debug enabled from ARGV')} 76 opts.on( '-h', '--help', 'Display this screen' ) { puts(opts); exit 1 } 77 opts.on( '-n', '--no-colors', 'Deactives colors (onta e disonore!)' ) { $colors_active = false } 78 opts.on( '-l', '--local', 'uses local instead' ) { $opts[:local] = true } 79 opts.on( '-t', '--timeout TIMEOUT', "Sets timeout (default =#{$opts[:timeout]}s)" ) {|new_timeout| 80 $opts[:timeout] = new_timeout.to_i rescue 5 81 RemoteTodo.timeout = new_timeout.to_i rescue 5 82 } 83 opts.on( '-v', '--verbose', 'Output more information' ) { $opts[:verbose] = true} 84 85 opts.banner = <<-API_OPTIONS 86 #{$0} v.#{$PROG_VER} 87 Usage: #{File.basename $0} [options] [add|list|done|del] [args] 88 89 API Actions (T stands for ToBeDoneYet ): 90 add <FREE TEXT> # adds new task in free text with some magic.. 91 delete <ID> # T delete ticket.ID (DONT USE IF U CAN!) 92 done <ID> # T posts ticket.ID :done (resolved) 93 edit <ID> [ACTION1:ARG1] [ACT2:ARG2]# T posts generic action for ticket.ID /edit.xml?due=tomorrow&ACT2=ARG2 94 list # shows a list of your todos yet to complete 95 mail <ID> # T mail to yourself ticket.ID !!! 96 show <ID> # shows details about todo with id=ID 97 procrastinate <ID> <NDAYS> # T mail to yourself ticket.ID !!! 98 sleep <ID> <NDAYS> # T mail to yourself ticket.ID !!! 99 100 Examples: 101 septober --local edit 110 due:tomorrow 102 septober list 103 septober show 1 104 septober add 'This is a ticket with priority 4 and a simple @example tag!' 105 106 Options: 107 API_OPTIONS 108 end 109 $optparse.parse! 110 RemoteTodo.import_config() 111 end
main()
click to toggle source
# File bin/ric 5 def main 6 require 'rubygems' 7 require 'ric' 8 include Ric::Colors 9 10 dir = File.dirname( File.dirname(__FILE__) + '/../..' ) 11 ver_manual = File.read( File.expand_path('VERSION',dir) ) 12 ver = Ric::Zibaldone.version rescue "UnknownVersionErr(#{$!})" 13 puts "#{$0} v.#{$ver} -- ARGS='#{ARGV.join(' ')}'" 14 puts "ric library version: ''#{ver_manual}'" 15 puts "Welcome to ric, the swiss-army knife tool from Riccardo,\n included in riclib gem (version=#{ver})" 16 pyellow 'ciao' rescue "Errors with color yellow: #{$!}" 17 Ric::Zibaldone.say_hello() 18 #Ric::Html.anything_to_html( {:simbolo => 'stringa' } ) 19 end
n()
click to toggle source
# File bin/riclib-test 24 def n 25 $count ||= -1 26 $count += 1 27 end
nputs(s)
click to toggle source
# File bin/riclib-test 29 def nputs(s) 30 puts "#{n} #{Time.now}: #{s}" 31 end
richiedi(str)
click to toggle source
# File bin/riclib-test 17 def richiedi(str) 18 avail = `gem list #{str}`.split("\n").select{|line| line.match( /#{str} /) }.join('') 19 ret = "Requiring: require '#{str}' [#{avail}].. " 20 ret += require( str.to_s ).to_s 21 ret 22 end
todo_add(words_from_argv)
click to toggle source
Adds a todo with just the subject, the server takes it and parses and does the magic to assing the correct ptoject and stuff..
# File bin/septober 276 def todo_add(words_from_argv) 277 puts bannerino( "Add('#{words_from_argv}')" ) 278 # TODO put this into begin/end/catch !!! 279 t = RemoteTodo.create( 280 :name => words_from_argv, 281 :description => "sent by CLI #{$0} v.#{$PROG_VER}, due tomorrow by test", 282 #:due => Date.tomorrow, 283 :where => Socket.gethostname, 284 :source => "CLI v.#{$PROG_VER}" 285 #:project_id => 5, 286 #:priority => 4 287 ) 288 deb "DEB todo: #{t}" 289 ret = t.save 290 puts "Some errors: '#{red t.errors.full_messages.to_s}'" if t.errors and t.errors.to_s != '' 291 if ret 292 puts "Todo created successfully: ##{green t.id.to_s}" # just provides the Id 293 else 294 pred "Some error saving todo: #{t.inspect}" 295 end 296 pgray "TODO get meaningful explaination from api/todos_controller!" 297 #puts "errors: #{ret.errors}" 298 end
todo_done(id,done_or_undone=true)
click to toggle source
# File bin/septober 306 def todo_done(id,done_or_undone=true) 307 todo_generic_put(id,:done) 308 end
todo_generic_put(id,action,opts={})
click to toggle source
# File bin/septober 313 def todo_generic_put(id,action,opts={}) 314 puts bannerino("GenericAction(#{action},#{id})") 315 begin 316 todo = RemoteTodo.find(id) 317 puts "Todo.#{id} ok #{green action}: #{yellow( todo.to_s )}" 318 put_options = { 319 :my_action => action, 320 :from_cli_in_test_ric => Socket.gethostname 321 }.merge( opts.fetch( :additional_args, {:nis => :bah } ) ) # if there are ,m good. Otherwise, "nisba" :) 322 deb "todo_generic_put(id=#{id},#{purple action}, #{gray opts.inspect})" 323 todo.put(action, put_options ) # test stuff 324 #todo.put(action, :my_action => action, :from_cli_in_test_ric => Socket.gethostname , additional_args) # test stuff 325 rescue ActiveResource::ResourceNotFound 326 puts "Sorry ResourceNotFound: #{red $!}" 327 exit 11 328 rescue ActiveResource::ServerError 329 puts "Sorry ServerError: #{red $!}" 330 exit 12 331 end 332 # todo is good 333 #todo.put(:generic_action, :my_action => action) 334 end
todo_list(opts={})
click to toggle source
# File bin/septober 262 def todo_list(opts={}) 263 show_only_active = opts.fetch :only_active, true 264 puts bannerino( "Index" ) 265 all = RemoteTodo.find(:all) 266 all.each{|todo| 267 puts( todo.show_entry ) unless( show_only_active && ! todo.active ) 268 #deb "Full ToString for #{white todo}:\n\t#{todo.inspect}" 269 } if all 270 end
todo_search(q)
click to toggle source
# File bin/septober 336 def todo_search(q) 337 puts "# Todo.Search('#{q}') (user: #{blue RemoteTodo.user})" 338 pred "To Be implemented Yet" 339 end
todo_show(id)
click to toggle source
# File bin/septober 300 def todo_show(id) 301 todo = RemoteTodo.find(id) 302 puts bannerino("Show(#{id})") 303 puts( todo.show_full_entry ) 304 end
todo_toggle(id,done_or_undone=true)
click to toggle source
# File bin/septober 309 def todo_toggle(id,done_or_undone=true) 310 todo_generic_put(id,:toggle) 311 end
usage(explaination=nil)
click to toggle source
# File bin/septober 341 def usage(explaination=nil) 342 puts $optparse 343 pred(explaination) if explaination 344 exit 85 345 end