Skip to content

Add a --configuration option to the index binary#628

Merged
jviotti merged 1 commit intomainfrom
config-option
Feb 3, 2026
Merged

Add a --configuration option to the index binary#628
jviotti merged 1 commit intomainfrom
config-option

Conversation

@jviotti
Copy link
Member

@jviotti jviotti commented Feb 3, 2026

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@augmentcode
Copy link

augmentcode bot commented Feb 3, 2026

🤖 Augment PR Summary

Summary: Adds a dedicated --configuration (-g) flag to the sourcemeta-one-index CLI to print the resolved/expanded configuration.

Changes:

  • Introduced a new --configuration option that reads the config (resolving relative paths, defaults, and built-in collection references) and outputs it as pretty JSON, then exits.
  • Removed the configuration JSON dump from --verbose output (verbose now focuses on progress/mapping logs).
  • Updated Makefile targets (sandbox-index and public) to invoke the index tool with --configuration for visibility into the effective config.
  • Added new CLI tests covering --configuration in both long and short forms.
  • Adjusted existing verbose CLI tests to no longer expect the config JSON to appear in verbose output.
  • Updated the community @sourcemeta/std failure test to exercise --configuration, and added an enterprise-only test validating successful expansion/printing of @sourcemeta/std/v0.

Technical Notes: Configuration output is prettified to stdout and the command exits early after reading the configuration JSON.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

if (app.contains("verbose")) {
sourcemeta::core::prettify(raw_configuration, std::cerr);
std::cerr << "\n";
if (app.contains("configuration")) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--configuration returns before the --url override block later in index_main, so invocations like ... --url <...> --configuration will print the non-overridden URL (and other derived values) rather than the effective configuration; the Makefile now calls this combination in sandbox-index. Is that the intended behavior for the new option?

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

sourcemeta::core::prettify(raw_configuration, std::cerr);
std::cerr << "\n";
if (app.contains("configuration")) {
sourcemeta::core::prettify(raw_configuration, std::cout);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In --configuration mode the JSON is written to stdout, but the program also prints the version banner to stdout at startup, so the overall stdout stream isn’t valid JSON (the new tests work around this via tail -n +2). If --configuration is meant for scripting/pipe use, this mixed output could be surprising.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 9 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/index/index.cc">

<violation number="1" location="src/index/index.cc:105">
P2: `--configuration` should be a read-only operation, but it still constructs `Output` before returning, which creates/scans the output directory. Consider moving the configuration-print/exit path before `Output` initialization so it doesn’t touch the filesystem when only dumping the configuration.</violation>
</file>

<file name="test/cli/index/enterprise/sourcemeta-std.sh">

<violation number="1" location="test/cli/index/enterprise/sourcemeta-std.sh:17">
P2: The pipeline only checks `tail`'s exit status, so a failure in the index command can be masked. Run the command separately (or capture its output) so `errexit` stops the test on failure.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

if (app.contains("verbose")) {
sourcemeta::core::prettify(raw_configuration, std::cerr);
std::cerr << "\n";
if (app.contains("configuration")) {
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: --configuration should be a read-only operation, but it still constructs Output before returning, which creates/scans the output directory. Consider moving the configuration-print/exit path before Output initialization so it doesn’t touch the filesystem when only dumping the configuration.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/index/index.cc, line 105:

<comment>`--configuration` should be a read-only operation, but it still constructs `Output` before returning, which creates/scans the output directory. Consider moving the configuration-print/exit path before `Output` initialization so it doesn’t touch the filesystem when only dumping the configuration.</comment>

<file context>
@@ -102,9 +102,10 @@ static auto index_main(const std::string_view &program,
-  if (app.contains("verbose")) {
-    sourcemeta::core::prettify(raw_configuration, std::cerr);
-    std::cerr << "\n";
+  if (app.contains("configuration")) {
+    sourcemeta::core::prettify(raw_configuration, std::cout);
+    std::cout << "\n";
</file context>
Fix with Cubic

}
EOF

"$1" "$TMP/one.json" "$TMP/output" --configuration | tail -n +2 > "$TMP/output.txt"
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The pipeline only checks tail's exit status, so a failure in the index command can be masked. Run the command separately (or capture its output) so errexit stops the test on failure.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/cli/index/enterprise/sourcemeta-std.sh, line 17:

<comment>The pipeline only checks `tail`'s exit status, so a failure in the index command can be masked. Run the command separately (or capture its output) so `errexit` stops the test on failure.</comment>

<file context>
@@ -0,0 +1,54 @@
+}
+EOF
+
+"$1" "$TMP/one.json" "$TMP/output" --configuration | tail -n +2 > "$TMP/output.txt"
+
+cat << EOF > "$TMP/expected.txt"
</file context>
Fix with Cubic

@jviotti jviotti merged commit 3b61598 into main Feb 3, 2026
6 checks passed
@jviotti jviotti deleted the config-option branch February 3, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant