fogbugz 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'fogbugz/common'
3
3
 
4
- check_api_url
5
-
6
4
  dispatch_subcommand __FILE__,
7
5
  :areas => 'List active areas.',
8
6
  :assign => 'Assign a case.',
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fogbugz/common'
3
+
4
+ check_api_url
5
+ check_api_token
6
+
7
+ parse_opts "usage: #{File::basename(__FILE__)} [options] <case> <estimate>", 2
8
+ do_api('edit', :ixBug => ARGV[0], :hrsCurrEst => ARGV[1])
@@ -4,8 +4,8 @@ require 'fogbugz/common'
4
4
  check_api_url
5
5
  check_api_token
6
6
 
7
- api_url = ENV['FOGBUGZ_API_URL']
8
- api_token = ENV['FOGBUGZ_API_TOKEN']
7
+ api_url = CONFIG[:api_url]
8
+ api_token = CONFIG[:api_token]
9
9
 
10
10
  parse_opts "usage: #{File::basename(__FILE__)} [options] <filter>", 1
11
11
 
@@ -1,14 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'fogbugz/common'
3
3
 
4
- check_api_url
5
-
6
4
  options = {}
7
5
  optparse = OptionParser.new do |opts|
8
- opts.banner = "usage: #{File::basename(__FILE__)} [options] <email>"
6
+ opts.banner = "usage: #{File::basename(__FILE__)} [options]"
7
+
8
+ options[:email] = nil
9
+ opts.on_tail('--email=<email>') do |password|
10
+ options[:email] = password
11
+ end
12
+
13
+ options[:api_url] = nil
14
+ opts.on_tail('--apiurl=<apiurl>') do |api_url|
15
+ options[:api_url] = api_url
16
+ end
9
17
 
10
18
  options[:password] = nil
11
- opts.on_tail('-p', '--password=<password>') do |password|
19
+ opts.on_tail('--password=<password>') do |password|
12
20
  options[:password] = password
13
21
  end
14
22
 
@@ -18,17 +26,15 @@ optparse = OptionParser.new do |opts|
18
26
  end
19
27
  end
20
28
  optparse.parse!
21
- unless ARGV.length == 1
22
- puts optparse.help
23
- exit 1
24
- end
25
29
 
30
+ api_url = options[:api_url] || CONFIG[:api_url] ||
31
+ HighLine.new.ask('API URL: ')
32
+ email = options[:email] || CONFIG[:email] ||
33
+ HighLine.new.ask('Email: ')
26
34
  password = options[:password] ||
27
35
  HighLine.new.ask('Password: ') { |q| q.echo = false }
28
36
 
29
- api_url = ENV['FOGBUGZ_API_URL']
30
-
31
- uri = URI("#{api_url}?cmd=logon&email=#{URI.escape(ARGV[0])}&" +
37
+ uri = URI("#{api_url}?cmd=logon&email=#{URI.escape(email)}&" +
32
38
  "password=#{URI.escape(password)}")
33
39
  http = Net::HTTP.new(uri.host, uri.port)
34
40
  if uri.scheme == 'https'
@@ -50,7 +56,8 @@ if error
50
56
  exit 1
51
57
  end
52
58
 
53
- puts <<HERE
54
- Login successful. Set the following environment variable:
55
- export FOGBUGZ_API_TOKEN=#{result.elements['/response/token'].text}
56
- HERE
59
+ puts "Login successful."
60
+ CONFIG[:email] = email
61
+ CONFIG[:api_url] = api_url
62
+ CONFIG[:api_token] = "#{result.elements['/response/token'].text}"
63
+ IO::write(CONFIG_FILE, CONFIG.to_yaml)
@@ -6,3 +6,6 @@ check_api_token
6
6
 
7
7
  parse_opts "usage: #{File::basename(__FILE__)} [options]", 0
8
8
  do_api 'logoff'
9
+
10
+ CONFIG[:api_token] = nil
11
+ IO::write(CONFIG_FILE, CONFIG.to_yaml)
@@ -9,6 +9,13 @@ require 'English'
9
9
  require 'time'
10
10
  require 'chronic'
11
11
 
12
+ CONFIG_FILE = Dir.home + '/.fogbugzrc'
13
+ begin
14
+ CONFIG = YAML::load(IO::read(CONFIG_FILE))
15
+ rescue
16
+ CONFIG = {}
17
+ end
18
+
12
19
  HighLine.use_color = STDOUT.isatty
13
20
  begin
14
21
  require 'win32console' if RUBY_PLATFORM =~ /mingw/
@@ -24,15 +31,15 @@ def m; HighLine.use_color? ? HighLine::MAGENTA : ''; end
24
31
  def c; HighLine.use_color? ? HighLine::CLEAR : ''; end
25
32
 
26
33
  def check_api_url
27
- unless ENV['FOGBUGZ_API_URL']
28
- puts "Environment variable FOGBUGZ_API_URL must be set."
34
+ unless CONFIG[:api_url]
35
+ puts "Not logged in."
29
36
  exit 1
30
37
  end
31
38
  end
32
39
 
33
40
  def check_api_token
34
- unless ENV['FOGBUGZ_API_TOKEN']
35
- puts "Environment variable FOGBUGZ_API_TOKEN must be set."
41
+ unless CONFIG[:api_token]
42
+ puts "Not logged in."
36
43
  exit 1
37
44
  end
38
45
  end
@@ -293,8 +300,8 @@ def maybe_literal(xml)
293
300
  end
294
301
 
295
302
  def do_api(cmd, params={})
296
- api_url = ENV['FOGBUGZ_API_URL']
297
- api_token = ENV['FOGBUGZ_API_TOKEN']
303
+ api_url = CONFIG[:api_url]
304
+ api_token = CONFIG[:api_token]
298
305
 
299
306
  query = ''
300
307
  params.each_pair do |k,v|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fogbugz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-11 00:00:00.000000000 Z
12
+ date: 2012-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
@@ -54,6 +54,7 @@ executables:
54
54
  - fogbugz-categories
55
55
  - fogbugz-close
56
56
  - fogbugz-edit
57
+ - fogbugz-estimate
57
58
  - fogbugz-filter
58
59
  - fogbugz-filters
59
60
  - fogbugz-list
@@ -81,6 +82,7 @@ files:
81
82
  - bin/fogbugz-categories
82
83
  - bin/fogbugz-close
83
84
  - bin/fogbugz-edit
85
+ - bin/fogbugz-estimate
84
86
  - bin/fogbugz-filter
85
87
  - bin/fogbugz-filters
86
88
  - bin/fogbugz-list