Skip to content

CLI: -d/--directory option for the remote working directory (winrs -d) - #155

Merged
bertysentry merged 4 commits into
mainfrom
feature/cli-directory-option
Aug 10, 2026
Merged

CLI: -d/--directory option for the remote working directory (winrs -d)#155
bertysentry merged 4 commits into
mainfrom
feature/cli-directory-option

Conversation

@bertysentry

Copy link
Copy Markdown
Contributor

Closes #138.

What

winrs parity for -d[irectory]:PATH: the command and shell subcommands now accept -d, --directory <path>, mapped straight to CommandRequest.workingDirectory(...) — the remote shell is created with rsp:WorkingDirectory, so the command (or the interactive cmd.exe session) starts in the requested directory instead of %USERPROFILE%.

winrm-java -h server -u 'DOMAIN\user' -pf pw.txt -d 'C:\build' exec build.cmd

Since a CLI invocation is one client running one command, the API's "first command only" pinning caveat always applies — the option simply works. For shell, the session opens its own connection whose first command is the shell itself, so it applies there too.

Details

  • -d was free (-h is the hostname short option); --directory is the long form.
  • Usage errors (exit 64): missing or blank value, and --directory with the wql subcommand.
  • --help gets one line; the full description lives in the CLI manual options table (updated in src/site/markdown/cli.md).

Tests

  • CliArgumentsTest: parsing of both forms, default null, missing/blank value, rejection with wql.
  • WinRmCliTest: pass-through to the remote operations for both command and shell, plus full-stack wire assertions against FakeWsmanServer that the Create shell request carries <rsp:WorkingDirectory> — for exec (new test) and for shell (extended code-page test).

mvn verify site is green: 189 tests + the standalone-jar IT pass, checkstyle/PMD/SpotBugs clean.

🤖 Generated with Claude Code

winrs parity (-d): the command and shell subcommands now accept
-d/--directory, mapped straight to CommandRequest.workingDirectory(...)
so the remote shell is created with rsp:WorkingDirectory. A missing or
blank value, or using the option with wql, is a usage error.

Closes #138

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7537aea6c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/site/markdown/cli.md
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bertysentry

Copy link
Copy Markdown
Contributor Author

@codex please review again

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: e8c20bde01

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…og features

README.md stays terse; src/site/markdown (cli.md for the CLI) is the
single source of truth for end-user documentation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bertysentry

Copy link
Copy Markdown
Contributor Author

@codex please review again

@bertysentry
bertysentry merged commit c069324 into main Aug 10, 2026
2 checks passed
@bertysentry
bertysentry deleted the feature/cli-directory-option branch August 10, 2026 19:15
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: a3cdf8a5e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

CLI: --directory option for the remote working directory (winrs -d)

1 participant