-
Notifications
You must be signed in to change notification settings - Fork 1
dor open: dispatch local files through user Tool associations #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5ad6971
Add local-file-only dor open dispatch through user Tools
nedtwigg cbfeb97
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg e372ab0
Support file glob matching on all supported hosts
nedtwigg 191c829
Disclose the bundled glob matcher
nedtwigg 46eb215
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg acd3241
Simplify dor open dispatch
nedtwigg f3a56a5
Preserve persistence timer tests and document open matching
nedtwigg 9813411
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 1a77a88
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 229a30d
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 469e86a
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 9274795
Cover invalid user open rules and align host lookup
nedtwigg a762373
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 0fa5ab7
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 359d38f
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 5ce2b30
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 65dc881
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 6c9b462
Fix open associations from symlinked working directories
nedtwigg 062a832
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 0a0d4ed
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg 238f1c6
Align the Tool spec budget after parent integration
nedtwigg d7cb82c
Name malformed Tool association fields accurately
nedtwigg 185c108
Merge branch 'dor-tool-inputs' into dor-open-dispatch
nedtwigg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { buildCommand } from '@stricli/core'; | ||
| import type { Command, DorCommandContext, WorkspaceScopedFlags } from './types.js'; | ||
| import { callerWorkingDirectory, stringParser, workspaceFlag, workspaceParam } from './shared.js'; | ||
| import { dispatchToolSurface } from './tool.js'; | ||
|
|
||
| interface OpenFlags extends WorkspaceScopedFlags { | ||
| readonly json?: boolean; | ||
| readonly minimize?: boolean; | ||
| readonly fresh?: boolean; | ||
| readonly surface?: string; | ||
| readonly cwd?: string; | ||
| readonly tool?: string; | ||
| } | ||
|
|
||
| export const openCommand: Command = { | ||
| name: 'open', | ||
| command: buildCommand<OpenFlags, [string], DorCommandContext>({ | ||
| docs: { | ||
| brief: 'Open a local file with a Dor Tool.', | ||
| fullDescription: `Opens one existing local file. Relative paths resolve from the caller's directory (or --cwd); symlink aliases resolve to the same file. URLs, directories, and Surface handles are not accepted. | ||
|
|
||
| The first matching rule in the user dormouse.yml selects a user Tool. --tool chooses a user Tool explicitly. Project associations and project Tools never participate in this lookup. The user file is $XDG_CONFIG_HOME/dormouse/dormouse.yml, or ~/.config/dormouse/dormouse.yml. | ||
|
|
||
| The ordered open list contains {match, tool} entries. Patterns without a slash match the filename; patterns with a slash match both the canonical absolute path and the path relative to the invocation directory. Matching uses picomatch glob syntax with forward slashes and case sensitivity. Dotfiles require explicit patterns. | ||
|
|
||
| The selected Tool receives the canonical absolute filename as one argument. Configure prespawn_dedupe: [$TARGET] to reveal the same file on repeated opens within a Workspace. --fresh bypasses reuse. | ||
|
|
||
| Opening creates a focus-neutral split or reveals an existing Tool, never taking over the caller's terminal. The command prints the Surface handle; --json prints structured output.`, | ||
| }, | ||
| parameters: { | ||
| flags: { | ||
| json: { kind: 'boolean', brief: 'Print JSON output.', optional: true, withNegated: false }, | ||
| minimize: { kind: 'boolean', brief: 'Create the surface minimized.', optional: true, withNegated: false }, | ||
| fresh: { kind: 'boolean', brief: 'Open another instance even when the Tool has a key.', optional: true, withNegated: false }, | ||
| surface: { kind: 'parsed', parse: stringParser, brief: 'Surface to split when creating.', optional: true, placeholder: 'id|ref' }, | ||
| workspace: workspaceFlag, | ||
| cwd: { kind: 'parsed', parse: stringParser, brief: 'Directory for resolving the file.', optional: true, placeholder: 'path' }, | ||
| tool: { kind: 'parsed', parse: stringParser, brief: 'Use this user-global Tool.', optional: true, placeholder: 'name' }, | ||
| }, | ||
| positional: { kind: 'tuple', parameters: [{ parse: stringParser, brief: 'Local file to open.', placeholder: 'file' }] }, | ||
| }, | ||
| func(this: DorCommandContext, flags: OpenFlags, file: string) { | ||
| return dispatchToolSurface(this, { | ||
| file, | ||
| tool: flags.tool, | ||
| ...workspaceParam(flags.workspace), | ||
| fresh: flags.fresh === true, | ||
| minimized: flags.minimize === true, | ||
| surface: flags.surface, | ||
| cwd: callerWorkingDirectory(flags.cwd, this.options.env), | ||
| }, flags.json === true); | ||
| }, | ||
| }), | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # dor open | ||
|
|
||
| Invocation: `dor open --help` | ||
|
|
||
| ```text | ||
| USAGE | ||
| dor open [--json] [--minimize] [--fresh] [--surface id|ref] [--workspace ref] [--cwd path] [--tool name] <file> | ||
| dor open --help | ||
|
|
||
| Opens one existing local file. Relative paths resolve from the caller's directory (or --cwd); symlink aliases resolve to the same file. URLs, directories, and Surface handles are not accepted. | ||
|
|
||
| The first matching rule in the user dormouse.yml selects a user Tool. --tool chooses a user Tool explicitly. Project associations and project Tools never participate in this lookup. The user file is $XDG_CONFIG_HOME/dormouse/dormouse.yml, or ~/.config/dormouse/dormouse.yml. | ||
|
|
||
| The ordered open list contains {match, tool} entries. Patterns without a slash match the filename; patterns with a slash match both the canonical absolute path and the path relative to the invocation directory. Matching uses picomatch glob syntax with forward slashes and case sensitivity. Dotfiles require explicit patterns. | ||
|
|
||
| The selected Tool receives the canonical absolute filename as one argument. Configure prespawn_dedupe: [$TARGET] to reveal the same file on repeated opens within a Workspace. --fresh bypasses reuse. | ||
|
|
||
| Opening creates a focus-neutral split or reveals an existing Tool, never taking over the caller's terminal. The command prints the Surface handle; --json prints structured output. | ||
|
|
||
| FLAGS | ||
| [--json] Print JSON output. | ||
| [--minimize] Create the surface minimized. | ||
| [--fresh] Open another instance even when the Tool has a key. | ||
| [--surface] Surface to split when creating. | ||
| [--workspace] Workspace to act in, instead of the caller's. | ||
| [--cwd] Directory for resolving the file. | ||
| [--tool] Use this user-global Tool. | ||
| -h --help Print help information and exit | ||
| -- All subsequent inputs should be interpreted as arguments | ||
|
|
||
| ARGUMENTS | ||
| file Local file to open. | ||
|
|
||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.