Skip to content

Comments

chore: allow igniter global options (--yes, --dry-run, etc.) to pass through to sync task#55

Merged
zachdaniel merged 2 commits intoash-project:mainfrom
nallwhy:chore/pass-igniter-options-to-sync
Feb 18, 2026
Merged

chore: allow igniter global options (--yes, --dry-run, etc.) to pass through to sync task#55
zachdaniel merged 2 commits intoash-project:mainfrom
nallwhy:chore/pass-igniter-options-to-sync

Conversation

@nallwhy
Copy link
Contributor

@nallwhy nallwhy commented Feb 17, 2026

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Previously, mix usage_rules.sync rejected all command-line arguments unconditionally. This was intended to guide users away from the old CLI-based configuration, but it also blocked Igniter's own global options like --yes.

Now the task parses argv against Igniter's global option schema and only rejects unrecognized arguments. Igniter flags pass through as expected:

  • mix usage_rules.sync --yes — apply changes without confirmation
  • mix usage_rules.sync --dry-run — preview changes only
  • mix usage_rules.sync --check — fail if changes are needed (useful in CI)

Copilot AI review requested due to automatic review settings February 17, 2026 06:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates mix usage_rules.sync to stop rejecting all CLI args and instead allow Igniter’s global flags (e.g., --yes, --dry-run) while still rejecting unsupported arguments, so the task works properly when invoked via Igniter tooling.

Changes:

  • Parse argv against Igniter’s global option switch schema before deciding whether to raise.
  • Raise only when non-global args are present, and document supported Igniter flags in the warning output.
Comments suppressed due to low confidence (1)

lib/mix/tasks/usage_rules.sync.ex:120

  • This change alters CLI behavior (allowing Igniter global flags and rejecting only certain args) but there are no tests covering run/1 argv parsing. Since there is already comprehensive test coverage for this task, please add tests that (1) mix usage_rules.sync --yes/--dry-run/--check does not raise and (2) an unknown flag or positional argument still raises with the expected message.
    def run(argv) do
      {_opts, remaining, invalid} =
        OptionParser.parse(argv, strict: Igniter.Mix.Task.Info.global_options()[:switches])

      if Enum.any?(remaining ++ invalid) do
        Mix.raise("""
        WARNING: `mix usage_rules.sync` no longer accepts command-line arguments.

        Configuration is now done in your `mix.exs` project config:

        #{__MODULE__.Docs.code_sample(4)}

        Then simply run: mix usage_rules.sync

        Supported flags (passed through to Igniter): --yes, --dry-run, --verbose, --check

        Run `mix help usage_rules.sync` for full configuration options.
        """)
      else
        super(argv)
      end

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 101 to 105
{_opts, remaining, invalid} =
OptionParser.parse(argv, strict: Igniter.Mix.Task.Info.global_options()[:switches])

if Enum.any?(remaining ++ invalid) do
Mix.raise("""
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

invalid from OptionParser.parse/2 can include recognized switches with invalid values (e.g., wrong type). The PR description says only unrecognized arguments should be rejected, but this condition will also raise for invalid values of known Igniter global flags, bypassing Igniter's own (more precise) error handling. Consider only rejecting remaining and unknown switches, or letting invalid for known global flags pass through to super(argv) and be handled by Igniter.

Copilot uses AI. Check for mistakes.
Comment on lines 106 to 116
@@ -108,6 +111,8 @@ if Code.ensure_loaded?(Igniter) do

Then simply run: mix usage_rules.sync

Supported flags (passed through to Igniter): --yes, --dry-run, --verbose, --check

Run `mix help usage_rules.sync` for full configuration options.
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The raised message says the task "no longer accepts command-line arguments" but then lists supported flags like --yes/--dry-run. This is internally inconsistent and may confuse users who passed an unsupported flag. Consider rewording to clarify that task-specific arguments are rejected but Igniter global flags are allowed (and keep the list of allowed flags separate from the warning).

Copilot uses AI. Check for mistakes.
@zachdaniel
Copy link
Contributor

The robot has some points (I think GH just turned this on for OSS PRs w/o asking? I'm not sure). But the main one is that we should clarify the wording slightly on the error message. Otherwise this makes perfect sense though and is a good catch, thank you 🙇

@nallwhy
Copy link
Contributor Author

nallwhy commented Feb 17, 2026

The robot has some points (I think GH just turned this on for OSS PRs w/o asking? I'm not sure). But the main one is that we should clarify the wording slightly on the error message. Otherwise this makes perfect sense though and is a good catch, thank you 🙇

I’ve updated the wording of the error message based on Copilot’s review to make it clearer that task-specific arguments are rejected, while Igniter global flags are still allowed.

I have Copilot set up to automatically review my PRs, so that’s why it showed up here.

On a slightly unrelated note — from your experience, when using usage_rules, did you find it better to work with CLAUDE.md, or with skills?

Thank you :)

@zachdaniel
Copy link
Contributor

I've found skills to be less effective generally.

@zachdaniel zachdaniel merged commit 2109bff into ash-project:main Feb 18, 2026
23 checks passed
@zachdaniel
Copy link
Contributor

🚀 Thank you for your contribution! 🚀

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.

2 participants