Class: TaskJuggler::Tj3Client
- Inherits:
-
Tj3AppBase
- Object
- Tj3AppBase
- TaskJuggler::Tj3Client
- Includes:
- DaemonConnectorMixin
- Defined in:
- lib/taskjuggler/apps/Tj3Client.rb
Overview
The Tj3Client class provides the primary interface to the TaskJuggler daemon. It exposes a rich commandline interface that supports key operations like add/removing a project, generating a report or checking a time or status sheet. All connections are made via DRb and tj3client requires a properly configured tj3d to work.
Instance Method Summary collapse
- #appMain(args) ⇒ Object
-
#initialize ⇒ Tj3Client
constructor
A new instance of Tj3Client.
- #processArguments(argv) ⇒ Object
Methods included from DaemonConnectorMixin
#connectDaemon, #disconnectDaemon
Methods included from MessageHandler
#critical, #debug, #error, #fatal, #info, #warning
Methods inherited from Tj3AppBase
Constructor Details
#initialize ⇒ Tj3Client
Returns a new instance of Tj3Client.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/taskjuggler/apps/Tj3Client.rb', line 33 def initialize super # For security reasons, this will probably not change. All DRb # operations are limited to localhost only. The client and the sever # must have access to the identical file system. @host = '127.0.0.1' # The default port. 'T' and 'J' in ASCII decimal @port = 8474 # The file with the server URI in case port is 0. @uriFile = File.join(Dir.getwd, '.tj3d.uri') # This must must be changed for the communication to work. @authKey = nil # Determines whether report IDs are fix IDs or regular expressions that # match a set of reports. @regExpMode = false # Prevents usage of protective sandbox if set to true. @unsafeMode = false # List of requested output formats for reports. @formats = nil @mandatoryArgs = '<command> [arg1 arg2 ...]' # This list describes the supported command line commands and their # parameter. # :label : The command name # :args : A list of parameters. If the first character is a '+' the # parameter must be provided 1 or more times. If the first character is # a '*' the parameter must be provided 0 or more times. Repeatable and # optional paramters must follow the mandatory ones. # :descr : A short description of the command used for the help text. @commands = [ { :label => 'status', :args => [], :descr => 'Display the status of the available projects' }, { :label => 'terminate', :args => [], :descr => 'Terminate the TaskJuggler daemon' }, { :label => 'add', :args => [ 'tjp file', '*tji file'], :descr => 'Add a new project or update and existing one' }, { :label => 'update', :args => [], :descr => 'Reload all projects that have modified files and '+ 'are not being reloaded already' }, { :label => 'remove', :args => [ '+project ID' ], :descr => 'Remove the project with the specified ID from the ' + 'daemon' }, { :label => 'report', :args => [ 'project ID', '+report ID', '!=', '*tji file'], :descr => 'Generate the report with the provided ID for ' + 'the project with the given ID'}, { :label => 'list-reports', :args => [ 'project ID', '!report ID' ], :descr => 'List all available reports of the project or those ' + 'that match the provided report ID' }, { :label => 'check-ts', :args => [ 'project ID', 'time sheet' ], :descr => 'Check the provided time sheet for correctness ' + 'against the project with the given ID'}, { :label => 'check-ss', :args => [ 'project ID', 'status sheet' ], :descr => 'Check the provided status sheet for correctness ' + 'against the project with the given ID'} ] end |
Instance Method Details
#appMain(args) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/taskjuggler/apps/Tj3Client.rb', line 165 def appMain(args) # Run a first check of the non-optional command line arguments. checkCommand(args) # Read some configuration variables. Except for the authKey, they are # all optional. @rc.configure(self, 'global') @broker = connectDaemon retVal = executeCommand(args[0], args[1..-1]) disconnectDaemon @broker = nil retVal end |
#processArguments(argv) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/taskjuggler/apps/Tj3Client.rb', line 101 def processArguments(argv) super do = <<'EOT' The TaskJuggler client is used to send commands and data to the TaskJuggler daemon. The communication is done via TCP/IP. The following commands are supported: EOT # Convert the command list into a help text. @commands.each do |cmd| tail = '' args = cmd[:args].dup args.map! do |c| if c[0] == '*' "[<#{c[1..-1]}> ...]" elsif c[0] == '+' "<#{c[1..-1]}> [<#{c[1..-1]}> ...]" elsif c[0] == '!' tail += ']' "[#{c[1..-1]} " else "<#{c}>" end end args = args.join(' ') += " #{cmd[:label] + ' ' + args + tail}" + "\n\n#{' ' * 10 + format(cmd[:descr], 10)}\n" end @opts..prepend() @opts.on('-p', '--port <NUMBER>', Integer, format('Use the specified TCP/IP port')) do |arg| @port = arg end @opts.on('--urifile <FILE>', String, format('If the port is 0, use this file to get the URI ' + 'of the server.')) do |arg| @uriFile = arg end @opts.on('-r', '--regexp', format('The report IDs are not fixed but regular ' + 'expressions that match a set of reports')) do |arg| @regExpMode = true end @opts.on('--unsafe', format('Run the program without sandbox protection. This ' + 'is not recommended for normal operation! It may ' + 'only be used for debugging or testing ' + 'purposes.')) do |arg| @unsafeMode = true end @opts.on('--format [FORMAT]', [ :csv, :html, :mspxml, :niku, :tjp ], format('Request the report to be generated in the specified' + 'format. Use multiple options to request multiple ' + 'formats. Supported formats are csv, html, niku and ' + 'tjp. By default, the formats specified in the ' + 'report definition are used.')) do |arg| @formats = [] unless @formats @formats << arg end end end |