Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-10-17 22:53:06 UTC using RuboCop version 1.81.1.
# on 2025-11-14 17:50:37 UTC using RuboCop version 1.81.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -24,21 +24,21 @@ Lint/MissingSuper:
- 'lib/skunk/cli/application.rb'
- 'lib/skunk/generators/html/overview.rb'

# Offense count: 4
# Offense count: 5
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 24

# Offense count: 14
# Offense count: 13
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 208

# Offense count: 5
# Offense count: 7
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 18
Max: 20

# Offense count: 1
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
Expand Down Expand Up @@ -66,10 +66,3 @@ Style/FrozenStringLiteralComment:
Exclude:
- '**/*.arb'
- 'bin/console'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Layout/LineLength:
Max: 124
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## main [(unreleased)](https://github.com/fastruby/skunk/compare/v0.5.4...HEAD)

* [FEATURE: Add `--formats` CLI flag to select report formats (json, html, console)](https://github.com/fastruby/skunk/pull/130)
* [REFACTOR: Move Console Report](https://github.com/fastruby/skunk/pull/128)
* [BUGFIX: Set the right content type in the share HTTP request](https://github.com/fastruby/skunk/pull/129)
* [REFACTOR: Centralize Skunk analysis into RubyCritic module](https://github.com/fastruby/skunk/pull/127)
Expand Down
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,33 @@ This should give you an idea if you're moving in the direction of maintaining th

### Setting Output Formats

Skunk provides a simple configuration class to control output formats programmatically. You can use `Skunk::Config` to set which formats should be generated when running Skunk.
Skunk supports multiple output formats and you can select them via CLI or programmatically.

**Supported formats:**
- `:json` - JSON report (default)
- `:json` - JSON report
- `:html` - HTML report with visual charts and tables
- `:console` - Console output (default)

#### CLI flag

You can choose one or more formats from the command line:

```
skunk --formats=json
skunk --f json,html
skunk --formats console,json
```

If omitted, Skunk defaults to `console`.

#### Programmatic configuration

You can also configure formats in code using `Skunk::Config`:

```ruby
require 'skunk/config'

# Set multiple formats
# Set multiple formats (equivalent to `--formats=json,html`)
Skunk::Config.formats = [:json, :html]

# Add a format to the existing list
Expand All @@ -177,7 +194,7 @@ Skunk::Config.add_format(:html)
Skunk::Config.remove_format(:json)

# Check supported formats
Skunk::Config.supported_formats # => [:json, :html]
Skunk::Config.supported_formats # => [:json, :html, :console]
Skunk::Config.supported_format?(:json) # => true

# Reset to defaults
Expand Down
5 changes: 5 additions & 0 deletions lib/skunk/cli/options/argv.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "rubycritic/cli/options/argv"
require "skunk/config"

module Skunk
module Cli
Expand All @@ -26,6 +27,10 @@ def parse
self.output_filename = filename
end

opts.on("-f", "--formats json,html,console", Array, "Output formats: json,html,console") do |list|
Skunk::Config.formats = Array(list).map(&:to_sym)
end

opts.on_tail("-v", "--version", "Show gem's version") do
self.mode = :version
end
Expand Down
15 changes: 15 additions & 0 deletions test/lib/skunk/cli/options/argv_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,19 @@
end
end
end

describe "#formats" do
after do
Skunk::Config.reset
end
context "passing --formats option" do
let(:argv) { ["--formats=json,html"] }

it "applies formats to Skunk::Config" do
parser = Skunk::Cli::Options::Argv.new(argv)
parser.parse
_(Skunk::Config.formats).must_equal %i[json html]
end
end
end
end
1 change: 1 addition & 0 deletions test/lib/skunk/commands/help_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Usage: skunk [options] [paths]
-b, --branch BRANCH Set branch to compare
-o, --out FILE Output report to file
-f, --formats json,html,console Output formats: json,html,console
-v, --version Show gem's version
-h, --help Show this message
HELP
Expand Down