bugsink-cli 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc4e718e40bae09f46946050bfd5a52133b1a7f1b4653bd5d74ac4b39eeeef44
4
- data.tar.gz: 04bc34a4dabc823fd3fd262b1b28e7174407e0cb922d5d6bd8e34ca526f0dedb
3
+ metadata.gz: 877f72a744295aab29d7782564f80dc3cc849c8edc9be48f906d4a0b649d4b50
4
+ data.tar.gz: 564602e02fb9a9452908ae2de23ac47e731050c84dd30b0b55996e24114b49e6
5
5
  SHA512:
6
- metadata.gz: a4af07cd5b996e3ded9cd7333a1f1f097f6c6720a3b41b4cea21e03b6631c53c08642122e1e78d5cfdd1706d4b462b8ec03e8b7a366942ff5456774b07178f2b
7
- data.tar.gz: 5c1303e396df707697e9fa08331720031cc39630367b4fbb0672769da9017cb0f9add4b0a38dbb9466d5e09c1b818a5640f008fa04266095e045a4263d600db6
6
+ metadata.gz: fcdaa759b4b22db34d4914522502b7e6fa7815ebd0e75746a604f8bffc1f4e2c8c467ec6b17399ac212dea93aed24a1c65dab9364040eacc69878bd3c73d254e
7
+ data.tar.gz: 12adad1cc8c2f9ab03548f5257ebc63b46f7adb7378336ef95571d46df1f184edf77a5e1ce860726f3dd82239efddfc4f842c1a6b6331c8cb072e2133db4ec57
data/README.md CHANGED
@@ -25,18 +25,24 @@ gem 'bugsink-cli', '~> 0.1.0'
25
25
 
26
26
  **Optional:**
27
27
  - `BUGSINK_HOST` - API host (default: `https://bugs.kopernici.cz`)
28
+ - `BUGSINK_PROJECT_ID` - Default project ID (takes precedence over `.bugsink` file)
28
29
 
29
30
  ### Project Configuration
30
31
 
31
- The CLI supports a `.bugsink` dotfile in your project root to store the default project ID:
32
+ The CLI supports two ways to set a default project ID:
32
33
 
33
- ```bash
34
- # Set default project
35
- bugsink config set-project 8
34
+ 1. **Environment Variable (recommended for CI/CD):**
35
+ ```bash
36
+ export BUGSINK_PROJECT_ID=8
37
+ ```
36
38
 
37
- # This creates .bugsink file with:
38
- PROJECT_ID=8
39
- ```
39
+ 2. **Local `.bugsink` file (recommended for development):**
40
+ ```bash
41
+ bugsink config set-project 8
42
+ # This creates .bugsink file with: PROJECT_ID=8
43
+ ```
44
+
45
+ **Note:** The environment variable takes precedence over the `.bugsink` file. When `BUGSINK_PROJECT_ID` is set, the `config set-project` command will not create a `.bugsink` file.
40
46
 
41
47
  ## Quick Start
42
48
 
@@ -47,7 +53,10 @@ export BUGSINK_API_KEY="your-token-here"
47
53
  # Test connection
48
54
  bugsink config test
49
55
 
50
- # Set default project
56
+ # Set default project (option 1: environment variable)
57
+ export BUGSINK_PROJECT_ID=8
58
+
59
+ # Or set default project (option 2: local file)
51
60
  bugsink config set-project 8
52
61
 
53
62
  # List latest issues
data/lib/bugsink/cli.rb CHANGED
@@ -396,11 +396,12 @@ module Bugsink
396
396
  bugsink releases create '{"project":8,"version":"v1.0"}'
397
397
 
398
398
  Environment Variables:
399
- BUGSINK_API_KEY API authentication token (required)
400
- BUGSINK_HOST API host (default: https://bugs.kopernici.cz)
399
+ BUGSINK_API_KEY API authentication token (required)
400
+ BUGSINK_HOST API host (default: https://bugs.kopernici.cz)
401
+ BUGSINK_PROJECT_ID Default project ID (takes precedence over .bugsink file)
401
402
 
402
403
  Configuration File:
403
- .bugsink Project ID for current directory
404
+ .bugsink Project ID for current directory (ignored if BUGSINK_PROJECT_ID is set)
404
405
 
405
406
  For resource-specific help:
406
407
  bugsink help <resource>
@@ -28,6 +28,13 @@ module Bugsink
28
28
  end
29
29
 
30
30
  def set_project_id(id)
31
+ if ENV['BUGSINK_PROJECT_ID'] && !ENV['BUGSINK_PROJECT_ID'].empty?
32
+ # Don't write to file if env var is set (env var takes precedence)
33
+ # Just update the in-memory value
34
+ @project_id = id
35
+ return
36
+ end
37
+
31
38
  File.write(dotfile_path, "PROJECT_ID=#{id}\n")
32
39
  @project_id = id
33
40
  end
@@ -37,17 +44,32 @@ module Bugsink
37
44
  end
38
45
 
39
46
  def to_s
47
+ project_display = if project_id
48
+ source = ENV['BUGSINK_PROJECT_ID'] && !ENV['BUGSINK_PROJECT_ID'].empty? ? 'env' : 'file'
49
+ "#{project_id} (from #{source})"
50
+ else
51
+ 'not set'
52
+ end
53
+
40
54
  <<~CONFIG
41
55
  BugSink Configuration:
42
56
  Host: #{host}
43
57
  API Key: #{api_key ? "#{api_key[0..8]}...#{api_key[-8..]}" : 'not set'}
44
- Project ID: #{project_id || 'not set'}
58
+ Project ID: #{project_display}
45
59
  CONFIG
46
60
  end
47
61
 
48
62
  private
49
63
 
50
64
  def read_project_id
65
+ # Check environment variable first (takes precedence)
66
+ env_project_id = ENV['BUGSINK_PROJECT_ID']
67
+ if env_project_id && !env_project_id.empty?
68
+ parsed = env_project_id.to_i
69
+ return parsed if parsed > 0 # Ensure it's a valid positive integer
70
+ end
71
+
72
+ # Fall back to dotfile
51
73
  return nil unless File.exist?(dotfile_path)
52
74
 
53
75
  content = File.read(dotfile_path).strip
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bugsink
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsink-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Kopernik