@drfed/drfed 0.0.0-stage → 0.1.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +1198 -2
- package/bin/drfed-account.mjs +20 -0
- package/bin/drfed-migrate.mjs +20 -0
- package/bin/drfed-server.mjs +20 -0
- package/bin/drfed-web.mjs +20 -0
- package/completions/bash/drfed-account +219 -0
- package/completions/bash/drfed-migrate +219 -0
- package/completions/bash/drfed-server +219 -0
- package/completions/bash/drfed-web +219 -0
- package/completions/fish/drfed-account.fish +264 -0
- package/completions/fish/drfed-migrate.fish +264 -0
- package/completions/fish/drfed-server.fish +264 -0
- package/completions/fish/drfed-web.fish +264 -0
- package/completions/nu/drfed-account.nu +293 -0
- package/completions/nu/drfed-migrate.nu +293 -0
- package/completions/nu/drfed-server.nu +293 -0
- package/completions/nu/drfed-web.nu +293 -0
- package/completions/pwsh/drfed-account.ps1 +183 -0
- package/completions/pwsh/drfed-migrate.ps1 +183 -0
- package/completions/pwsh/drfed-server.ps1 +183 -0
- package/completions/pwsh/drfed-web.ps1 +183 -0
- package/completions/zsh/_drfed-account +145 -0
- package/completions/zsh/_drfed-migrate +145 -0
- package/completions/zsh/_drfed-server +145 -0
- package/completions/zsh/_drfed-web +145 -0
- package/dist/api-mail-parser.d.mts +106 -0
- package/dist/api-mail-parser.d.mts.map +1 -0
- package/dist/api-mail-parser.mjs +145 -0
- package/dist/api-mail-parser.mjs.map +1 -0
- package/dist/api-mail-settings-BcGaqQ9f.d.mts +142 -0
- package/dist/api-mail-settings-BcGaqQ9f.d.mts.map +1 -0
- package/dist/api-mail-settings.d.mts +2 -0
- package/dist/api-mail-settings.mjs +272 -0
- package/dist/api-mail-settings.mjs.map +1 -0
- package/dist/bounded-mail-runtime.d.mts +9 -0
- package/dist/bounded-mail-runtime.d.mts.map +1 -0
- package/dist/bounded-mail-runtime.mjs +66 -0
- package/dist/bounded-mail-runtime.mjs.map +1 -0
- package/dist/commands/account-create.d.mts +37 -0
- package/dist/commands/account-create.d.mts.map +1 -0
- package/dist/commands/account-create.mjs +87 -0
- package/dist/commands/account-create.mjs.map +1 -0
- package/dist/commands/account-program.d.mts +223 -0
- package/dist/commands/account-program.d.mts.map +1 -0
- package/dist/commands/account-program.mjs +116 -0
- package/dist/commands/account-program.mjs.map +1 -0
- package/dist/commands/account.d.mts +6 -0
- package/dist/commands/account.d.mts.map +1 -0
- package/dist/commands/account.mjs +91 -0
- package/dist/commands/account.mjs.map +1 -0
- package/dist/commands/migrate-program.d.mts +219 -0
- package/dist/commands/migrate-program.d.mts.map +1 -0
- package/dist/commands/migrate-program.mjs +116 -0
- package/dist/commands/migrate-program.mjs.map +1 -0
- package/dist/commands/migrate.d.mts +6 -0
- package/dist/commands/migrate.d.mts.map +1 -0
- package/dist/commands/migrate.mjs +85 -0
- package/dist/commands/migrate.mjs.map +1 -0
- package/dist/commands/web-program.d.mts +213 -0
- package/dist/commands/web-program.d.mts.map +1 -0
- package/dist/commands/web-program.mjs +112 -0
- package/dist/commands/web-program.mjs.map +1 -0
- package/dist/commands/web.d.mts +6 -0
- package/dist/commands/web.d.mts.map +1 -0
- package/dist/commands/web.mjs +184 -0
- package/dist/commands/web.mjs.map +1 -0
- package/dist/configuration-DVVF7xNv.d.mts +432 -0
- package/dist/configuration-DVVF7xNv.d.mts.map +1 -0
- package/dist/configuration.d.mts +2 -0
- package/dist/configuration.mjs +469 -0
- package/dist/configuration.mjs.map +1 -0
- package/dist/data-path.d.mts +9 -0
- package/dist/data-path.d.mts.map +1 -0
- package/dist/data-path.mjs +21 -0
- package/dist/data-path.mjs.map +1 -0
- package/dist/database-runtime.d.mts +26 -0
- package/dist/database-runtime.d.mts.map +1 -0
- package/dist/database-runtime.mjs +92 -0
- package/dist/database-runtime.mjs.map +1 -0
- package/dist/database-settings.d.mts +36 -0
- package/dist/database-settings.d.mts.map +1 -0
- package/dist/database-settings.mjs +67 -0
- package/dist/database-settings.mjs.map +1 -0
- package/dist/diagnostics.d.mts +29 -0
- package/dist/diagnostics.d.mts.map +1 -0
- package/dist/diagnostics.mjs +61 -0
- package/dist/diagnostics.mjs.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +344 -0
- package/dist/index.mjs.map +1 -0
- package/dist/jmap-parser.d.mts +35 -0
- package/dist/jmap-parser.d.mts.map +1 -0
- package/dist/jmap-parser.mjs +42 -0
- package/dist/jmap-parser.mjs.map +1 -0
- package/dist/jmap-runtime.d.mts +10 -0
- package/dist/jmap-runtime.d.mts.map +1 -0
- package/dist/jmap-runtime.mjs +17 -0
- package/dist/jmap-runtime.mjs.map +1 -0
- package/dist/jmap-settings-BXNAF1ep.d.mts +41 -0
- package/dist/jmap-settings-BXNAF1ep.d.mts.map +1 -0
- package/dist/jmap-settings.d.mts +2 -0
- package/dist/jmap-settings.mjs +104 -0
- package/dist/jmap-settings.mjs.map +1 -0
- package/dist/logging.d.mts +33 -0
- package/dist/logging.d.mts.map +1 -0
- package/dist/logging.mjs +56 -0
- package/dist/logging.mjs.map +1 -0
- package/dist/mail-parser-DyI4wuQp.d.mts +246 -0
- package/dist/mail-parser-DyI4wuQp.d.mts.map +1 -0
- package/dist/mail-parser.d.mts +2 -0
- package/dist/mail-parser.mjs +100 -0
- package/dist/mail-parser.mjs.map +1 -0
- package/dist/mail-runtime-YROIQ8up.mjs +314 -0
- package/dist/mail-runtime-YROIQ8up.mjs.map +1 -0
- package/dist/mail-runtime.d.mts +68 -0
- package/dist/mail-runtime.d.mts.map +1 -0
- package/dist/mail-runtime.mjs +2 -0
- package/dist/mail-settings-BD1TQ0rt.mjs +427 -0
- package/dist/mail-settings-BD1TQ0rt.mjs.map +1 -0
- package/dist/mail-settings-DjWMAUaE.d.mts +80 -0
- package/dist/mail-settings-DjWMAUaE.d.mts.map +1 -0
- package/dist/mail-settings.d.mts +2 -0
- package/dist/mail-settings.mjs +2 -0
- package/dist/operations.d.mts +32 -0
- package/dist/operations.d.mts.map +1 -0
- package/dist/operations.mjs +55 -0
- package/dist/operations.mjs.map +1 -0
- package/dist/package-7FOUqcPO.mjs +6 -0
- package/dist/package-7FOUqcPO.mjs.map +1 -0
- package/dist/parser-DGIQTgS7.mjs +178 -0
- package/dist/parser-DGIQTgS7.mjs.map +1 -0
- package/dist/parser-TANGHRjL.d.mts +305 -0
- package/dist/parser-TANGHRjL.d.mts.map +1 -0
- package/dist/postgres-settings.d.mts +20 -0
- package/dist/postgres-settings.d.mts.map +1 -0
- package/dist/postgres-settings.mjs +60 -0
- package/dist/postgres-settings.mjs.map +1 -0
- package/dist/query-logger.d.mts +9 -0
- package/dist/query-logger.d.mts.map +1 -0
- package/dist/query-logger.mjs +17 -0
- package/dist/query-logger.mjs.map +1 -0
- package/dist/resources.d.mts +20 -0
- package/dist/resources.d.mts.map +1 -0
- package/dist/resources.mjs +34 -0
- package/dist/resources.mjs.map +1 -0
- package/dist/secret-source-BeZx72Ue.d.mts +21 -0
- package/dist/secret-source-BeZx72Ue.d.mts.map +1 -0
- package/dist/secret-source.d.mts +2 -0
- package/dist/secret-source.mjs +58 -0
- package/dist/secret-source.mjs.map +1 -0
- package/dist/serving.d.mts +82 -0
- package/dist/serving.d.mts.map +1 -0
- package/dist/serving.mjs +138 -0
- package/dist/serving.mjs.map +1 -0
- package/dist/smtp-settings.d.mts +11 -0
- package/dist/smtp-settings.d.mts.map +1 -0
- package/dist/smtp-settings.mjs +38 -0
- package/dist/smtp-settings.mjs.map +1 -0
- package/dist/valueparser.d.mts +46 -0
- package/dist/valueparser.d.mts.map +1 -0
- package/dist/valueparser.mjs +121 -0
- package/dist/valueparser.mjs.map +1 -0
- package/package.json +275 -3
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
|
|
2
|
+
Register-ArgumentCompleter -Native -CommandName drfed-web -ScriptBlock {
|
|
3
|
+
param($wordToComplete, $commandAst, $cursorPosition)
|
|
4
|
+
|
|
5
|
+
# Extract arguments from AST (handles quoted strings properly)
|
|
6
|
+
$arguments = @()
|
|
7
|
+
$commandElements = $commandAst.CommandElements
|
|
8
|
+
|
|
9
|
+
# Determine the range of elements to extract
|
|
10
|
+
# Exclude the last element if it matches wordToComplete (partial input case)
|
|
11
|
+
$maxIndex = $commandElements.Count - 1
|
|
12
|
+
if ($commandElements.Count -gt 1) {
|
|
13
|
+
$lastElement = $commandElements[$commandElements.Count - 1]
|
|
14
|
+
$lastText = if ($lastElement -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
|
|
15
|
+
$lastElement.Value
|
|
16
|
+
} else {
|
|
17
|
+
$lastElement.Extent.Text
|
|
18
|
+
}
|
|
19
|
+
if ($lastText -eq $wordToComplete) {
|
|
20
|
+
$maxIndex = $commandElements.Count - 2
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for ($i = 1; $i -le $maxIndex; $i++) {
|
|
25
|
+
$element = $commandElements[$i]
|
|
26
|
+
|
|
27
|
+
if ($element -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
|
|
28
|
+
$arguments += $element.Value
|
|
29
|
+
} else {
|
|
30
|
+
$arguments += $element.Extent.Text
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Build arguments array for completion command
|
|
35
|
+
$completionArgs = @()
|
|
36
|
+
$completionArgs += @('completion', 'pwsh')
|
|
37
|
+
$completionArgs += $arguments
|
|
38
|
+
$completionArgs += $wordToComplete
|
|
39
|
+
|
|
40
|
+
# Call completion command and capture output
|
|
41
|
+
try {
|
|
42
|
+
$output = & drfed-web $completionArgs 2>$null
|
|
43
|
+
if (-not $output) { return }
|
|
44
|
+
|
|
45
|
+
# Parse tab-separated output and create CompletionResult objects
|
|
46
|
+
$output -split "`n" | ForEach-Object {
|
|
47
|
+
$line = $_.Trim()
|
|
48
|
+
if (-not $line) { return }
|
|
49
|
+
|
|
50
|
+
if ($line -match '^__FILE__:') {
|
|
51
|
+
# Parse file completion directive: __FILE__:type:extensions:pattern:hidden
|
|
52
|
+
$directive = ($line -split "`t")[0]
|
|
53
|
+
$parts = $directive -split ':', 5
|
|
54
|
+
$type = $parts[1]
|
|
55
|
+
$extensions = $parts[2]
|
|
56
|
+
$pattern = $parts[3] -replace '%3A', ':' -replace '%25', '%'
|
|
57
|
+
$hidden = $parts[4] -eq '1'
|
|
58
|
+
|
|
59
|
+
# When a pattern is specified, use it as the file matching
|
|
60
|
+
# prefix instead of the current word. If the user has
|
|
61
|
+
# already typed beyond the pattern, keep their input for
|
|
62
|
+
# incremental narrowing. Normalize path separators before
|
|
63
|
+
# comparing so that Windows backslashes match forward slashes
|
|
64
|
+
# in the transported pattern.
|
|
65
|
+
$normalizedPattern = if ($pattern) { $pattern.Replace('\', '/') -replace '^\./','' } else { '' }
|
|
66
|
+
$normalizedWord = if ($wordToComplete) { $wordToComplete.Replace('\', '/') -replace '^\./','' } else { '' }
|
|
67
|
+
$comparison = if ($IsWindows) { [System.StringComparison]::OrdinalIgnoreCase } else { [System.StringComparison]::Ordinal }
|
|
68
|
+
# For wildcard patterns, compare only the directory prefix
|
|
69
|
+
$comparePattern = $normalizedPattern
|
|
70
|
+
if ($comparePattern -match '[*?]') {
|
|
71
|
+
$beforeWild = $comparePattern -replace '[*?].*', ''
|
|
72
|
+
if ($beforeWild.Contains('/')) {
|
|
73
|
+
$comparePattern = $beforeWild.Substring(0, $beforeWild.LastIndexOf('/') + 1)
|
|
74
|
+
} else {
|
|
75
|
+
$comparePattern = ''
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
$prefix = if (($comparePattern -or $normalizedWord) -and $normalizedWord -and $normalizedWord.StartsWith($comparePattern, $comparison) -and $normalizedWord.Length -ge $comparePattern.Length -and $wordToComplete -ne $pattern) {
|
|
79
|
+
$wordToComplete
|
|
80
|
+
} elseif ($pattern) {
|
|
81
|
+
$pattern
|
|
82
|
+
} elseif ($wordToComplete) {
|
|
83
|
+
$wordToComplete
|
|
84
|
+
} else { '' }
|
|
85
|
+
|
|
86
|
+
# Use -Force to include hidden files when requested, or when
|
|
87
|
+
# the prefix basename targets dotfiles (e.g., src/.e)
|
|
88
|
+
$prefixBasename = if ($prefix) { Split-Path -Leaf $prefix } else { '' }
|
|
89
|
+
$forceParam = if ($hidden -or ($prefixBasename -and $prefixBasename.StartsWith('.'))) { @{Force = $true} } else { @{} }
|
|
90
|
+
|
|
91
|
+
# If prefix is a directory without trailing slash, append
|
|
92
|
+
# one so Get-ChildItem lists its contents
|
|
93
|
+
if ($prefix -and (Test-Path -Path $prefix -PathType Container) -and -not $prefix.EndsWith('/') -and -not $prefix.EndsWith('\')) {
|
|
94
|
+
$prefix = $prefix + '/'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
# Build the glob path—when the prefix contains wildcard
|
|
98
|
+
# characters, use it as-is; otherwise append *
|
|
99
|
+
$globPath = if ($prefix -match '[*?]') { $prefix } else { "${prefix}*" }
|
|
100
|
+
|
|
101
|
+
# Get file system items based on type
|
|
102
|
+
$items = @()
|
|
103
|
+
switch ($type) {
|
|
104
|
+
'file' {
|
|
105
|
+
if ($extensions) {
|
|
106
|
+
# Filter by extensions, always include directories
|
|
107
|
+
$extList = ($extensions -split ',') -replace '^\.',''
|
|
108
|
+
$items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue |
|
|
109
|
+
Where-Object {
|
|
110
|
+
$_.PSIsContainer -or (($_.Extension -replace '^\.','' ) -in $extList)
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
$items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
'directory' {
|
|
117
|
+
$items = Get-ChildItem @forceParam -Directory -Path $globPath -ErrorAction SilentlyContinue
|
|
118
|
+
}
|
|
119
|
+
'any' {
|
|
120
|
+
if ($extensions) {
|
|
121
|
+
# Filter by extensions, always include directories
|
|
122
|
+
$extList = ($extensions -split ',') -replace '^\.',''
|
|
123
|
+
$items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue |
|
|
124
|
+
Where-Object {
|
|
125
|
+
$_.PSIsContainer -or (($_.Extension -replace '^\.','' ) -in $extList)
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
$items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# For file/any modes with glob patterns, also add directories
|
|
134
|
+
# from the base directory for navigation
|
|
135
|
+
if ($prefix -match '[*?]' -and $type -ne 'directory') {
|
|
136
|
+
$globDir = Split-Path -Parent $prefix
|
|
137
|
+
if (-not $globDir) { $globDir = '.' }
|
|
138
|
+
$extraDirs = Get-ChildItem @forceParam -Directory -Path "$globDir/*" -ErrorAction SilentlyContinue
|
|
139
|
+
if ($extraDirs) { $items = @($items) + @($extraDirs) | Select-Object -Unique }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
# Filter hidden files unless requested or the prefix targets dotfiles
|
|
143
|
+
if (-not $hidden -and -not ($prefixBasename -and $prefixBasename.StartsWith('.'))) {
|
|
144
|
+
$items = $items | Where-Object { -not $_.Attributes.HasFlag([System.IO.FileAttributes]::Hidden) }
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
# Extract directory prefix to preserve in completion text
|
|
148
|
+
$dirPrefix = if ($prefix -and ($prefix.Contains('/') -or $prefix.Contains('\'))) {
|
|
149
|
+
$slashIdx = [Math]::Max($prefix.LastIndexOf('/'), $prefix.LastIndexOf('\'))
|
|
150
|
+
$prefix.Substring(0, $slashIdx + 1)
|
|
151
|
+
} else { '' }
|
|
152
|
+
|
|
153
|
+
# Create completion results for files
|
|
154
|
+
$items | ForEach-Object {
|
|
155
|
+
$completionText = if ($_.PSIsContainer) { "$dirPrefix$($_.Name)/" } else { "$dirPrefix$($_.Name)" }
|
|
156
|
+
$itemType = if ($_.PSIsContainer) { 'Directory' } else { 'File' }
|
|
157
|
+
[System.Management.Automation.CompletionResult]::new(
|
|
158
|
+
$completionText,
|
|
159
|
+
$completionText,
|
|
160
|
+
'ParameterValue',
|
|
161
|
+
$itemType
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
# Parse literal completion: text\tlistItemText\tdescription
|
|
166
|
+
$parts = $line -split "`t", 3
|
|
167
|
+
$completionText = $parts[0]
|
|
168
|
+
$listItemText = if ($parts.Length -gt 1 -and $parts[1]) { $parts[1] } else { $completionText }
|
|
169
|
+
$toolTip = if ($parts.Length -gt 2 -and $parts[2]) { $parts[2] } else { $completionText }
|
|
170
|
+
|
|
171
|
+
[System.Management.Automation.CompletionResult]::new(
|
|
172
|
+
$completionText,
|
|
173
|
+
$listItemText,
|
|
174
|
+
'ParameterValue',
|
|
175
|
+
$toolTip
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} catch {
|
|
180
|
+
# Silently ignore errors
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#compdef drfed-account
|
|
2
|
+
function _drfed_account () {
|
|
3
|
+
local current="$words[CURRENT]"
|
|
4
|
+
local -a prev
|
|
5
|
+
# Extract previous arguments, skipping empty ones
|
|
6
|
+
prev=()
|
|
7
|
+
local i
|
|
8
|
+
for (( i=2; i < CURRENT; i++ )); do
|
|
9
|
+
if [[ -n "$words[i]" ]]; then
|
|
10
|
+
prev+=("$words[i]")
|
|
11
|
+
fi
|
|
12
|
+
done
|
|
13
|
+
|
|
14
|
+
# Call the completion function and capture output
|
|
15
|
+
local output
|
|
16
|
+
if (( ${#prev[@]} == 0 )); then
|
|
17
|
+
output=$(drfed-account 'completion' 'zsh' "$current" 2>/dev/null)
|
|
18
|
+
else
|
|
19
|
+
output=$(drfed-account 'completion' 'zsh' "${prev[@]}" "$current" 2>/dev/null)
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# Split output into lines and process each line
|
|
23
|
+
local -a completions descriptions
|
|
24
|
+
local line value desc
|
|
25
|
+
local has_file_completion=0
|
|
26
|
+
|
|
27
|
+
while IFS= read -r line; do
|
|
28
|
+
if [[ -n "$line" ]]; then
|
|
29
|
+
# Split by null character - first part is value, second is description
|
|
30
|
+
value=${line%%$'\0'*}
|
|
31
|
+
desc=${line#*$'\0'}
|
|
32
|
+
desc=${desc%%$'\0'*}
|
|
33
|
+
|
|
34
|
+
if [[ "$value" == __FILE__:* ]]; then
|
|
35
|
+
# Parse file completion directive: __FILE__:type:extensions:pattern:hidden
|
|
36
|
+
local type extensions pattern hidden
|
|
37
|
+
IFS=':' read -r _ type extensions pattern hidden <<< "$value"
|
|
38
|
+
pattern="${pattern//%3A/:}"; pattern="${pattern//%25/%}"
|
|
39
|
+
has_file_completion=1
|
|
40
|
+
|
|
41
|
+
# Native completion helpers expect normal zsh glob grouping even if
|
|
42
|
+
# the caller enabled SH_GLOB in their shell options.
|
|
43
|
+
local __was_sh_glob=0
|
|
44
|
+
[[ -o sh_glob ]] && __was_sh_glob=1
|
|
45
|
+
unsetopt sh_glob
|
|
46
|
+
|
|
47
|
+
# Enable glob_dots when hidden files are requested so that
|
|
48
|
+
# _files and _directories include dot-prefixed entries
|
|
49
|
+
local __was_glob_dots=0
|
|
50
|
+
[[ -o glob_dots ]] && __was_glob_dots=1
|
|
51
|
+
if [[ "$hidden" == "1" ]]; then setopt glob_dots; fi
|
|
52
|
+
|
|
53
|
+
# When a pattern is specified, override PREFIX so that _files and
|
|
54
|
+
# _directories enumerate the pattern's directory instead of the
|
|
55
|
+
# current word. If the user has already typed beyond the pattern,
|
|
56
|
+
# keep PREFIX unchanged for incremental narrowing.
|
|
57
|
+
local __saved_prefix="$PREFIX"
|
|
58
|
+
if [[ -n "$pattern" ]]; then
|
|
59
|
+
# Normalize leading ./ so that ./src/ma matches pattern src/
|
|
60
|
+
local __norm_prefix="${PREFIX#./}"
|
|
61
|
+
local __norm_pattern="${pattern#./}"
|
|
62
|
+
local __compare_pattern="$__norm_pattern"
|
|
63
|
+
if [[ "$__compare_pattern" == *[*?]* ]]; then
|
|
64
|
+
__compare_pattern="${__compare_pattern%%[*?]*}"
|
|
65
|
+
[[ "$__compare_pattern" == */* ]] && __compare_pattern="${__compare_pattern%/*}/" || __compare_pattern=""
|
|
66
|
+
fi
|
|
67
|
+
if [[ ( -n "$__compare_pattern" || -n "$__norm_prefix" ) && ${#__norm_prefix} -ge ${#__compare_pattern} && "${__norm_prefix[1,${#__compare_pattern}]}" == "$__compare_pattern" && "$PREFIX" != "$pattern" ]]; then
|
|
68
|
+
# User typed an equivalent or extended form—keep PREFIX
|
|
69
|
+
true
|
|
70
|
+
else
|
|
71
|
+
PREFIX="$pattern"
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
local ext_pattern=""
|
|
76
|
+
if [[ -n "$extensions" ]]; then
|
|
77
|
+
if [[ "$extensions" == *,* ]]; then
|
|
78
|
+
ext_pattern="*.(${extensions//,/|})"
|
|
79
|
+
else
|
|
80
|
+
ext_pattern="*.$extensions"
|
|
81
|
+
fi
|
|
82
|
+
fi
|
|
83
|
+
# Use zsh's native file completion
|
|
84
|
+
case "$type" in
|
|
85
|
+
file)
|
|
86
|
+
if [[ -n "$ext_pattern" ]]; then
|
|
87
|
+
# Route filtered files through zsh's standard files/directories
|
|
88
|
+
# tags so files-tag styles and tag-order still apply, while
|
|
89
|
+
# avoiding _files' all-files fallback for extension-filtered
|
|
90
|
+
# matches.
|
|
91
|
+
local file_pattern="${ext_pattern}(#q-.)"
|
|
92
|
+
_wanted files expl file _path_files -g "${file_pattern}"
|
|
93
|
+
_wanted directories expl directory _path_files -/
|
|
94
|
+
else
|
|
95
|
+
_files
|
|
96
|
+
fi
|
|
97
|
+
;;
|
|
98
|
+
directory)
|
|
99
|
+
_directories
|
|
100
|
+
;;
|
|
101
|
+
any)
|
|
102
|
+
if [[ -n "$ext_pattern" ]]; then
|
|
103
|
+
local file_pattern="${ext_pattern}(#q^-/)"
|
|
104
|
+
_wanted files expl file _path_files -g "${file_pattern}"
|
|
105
|
+
_wanted directories expl directory _path_files -/
|
|
106
|
+
else
|
|
107
|
+
_files
|
|
108
|
+
fi
|
|
109
|
+
;;
|
|
110
|
+
esac
|
|
111
|
+
|
|
112
|
+
# Restore PREFIX and glob_dots to their previous state
|
|
113
|
+
PREFIX="$__saved_prefix"
|
|
114
|
+
if [[ "$__was_sh_glob" == "1" ]]; then setopt sh_glob; else unsetopt sh_glob; fi
|
|
115
|
+
if [[ "$__was_glob_dots" == "1" ]]; then setopt glob_dots; else unsetopt glob_dots; fi
|
|
116
|
+
else
|
|
117
|
+
# Regular literal completion
|
|
118
|
+
if [[ -n "$value" ]]; then
|
|
119
|
+
completions+=("$value")
|
|
120
|
+
descriptions+=("$desc")
|
|
121
|
+
fi
|
|
122
|
+
fi
|
|
123
|
+
fi
|
|
124
|
+
done <<< "$output"
|
|
125
|
+
|
|
126
|
+
# Add literal completions with descriptions if we have any
|
|
127
|
+
if (( ${#completions[@]} > 0 )); then
|
|
128
|
+
# Prepare completion with descriptions for _describe
|
|
129
|
+
local -a matches
|
|
130
|
+
local -i i
|
|
131
|
+
for (( i=1; i <= ${#completions[@]}; i++ )); do
|
|
132
|
+
if [[ -n "${descriptions[i]}" ]]; then
|
|
133
|
+
matches+=("${completions[i]}:${descriptions[i]}")
|
|
134
|
+
else
|
|
135
|
+
matches+=("${completions[i]}")
|
|
136
|
+
fi
|
|
137
|
+
done
|
|
138
|
+
_describe 'commands' matches
|
|
139
|
+
fi
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (( $+functions[compdef] )); then
|
|
143
|
+
compdef _drfed_account drfed-account
|
|
144
|
+
fi
|
|
145
|
+
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#compdef drfed-migrate
|
|
2
|
+
function _drfed_migrate () {
|
|
3
|
+
local current="$words[CURRENT]"
|
|
4
|
+
local -a prev
|
|
5
|
+
# Extract previous arguments, skipping empty ones
|
|
6
|
+
prev=()
|
|
7
|
+
local i
|
|
8
|
+
for (( i=2; i < CURRENT; i++ )); do
|
|
9
|
+
if [[ -n "$words[i]" ]]; then
|
|
10
|
+
prev+=("$words[i]")
|
|
11
|
+
fi
|
|
12
|
+
done
|
|
13
|
+
|
|
14
|
+
# Call the completion function and capture output
|
|
15
|
+
local output
|
|
16
|
+
if (( ${#prev[@]} == 0 )); then
|
|
17
|
+
output=$(drfed-migrate 'completion' 'zsh' "$current" 2>/dev/null)
|
|
18
|
+
else
|
|
19
|
+
output=$(drfed-migrate 'completion' 'zsh' "${prev[@]}" "$current" 2>/dev/null)
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# Split output into lines and process each line
|
|
23
|
+
local -a completions descriptions
|
|
24
|
+
local line value desc
|
|
25
|
+
local has_file_completion=0
|
|
26
|
+
|
|
27
|
+
while IFS= read -r line; do
|
|
28
|
+
if [[ -n "$line" ]]; then
|
|
29
|
+
# Split by null character - first part is value, second is description
|
|
30
|
+
value=${line%%$'\0'*}
|
|
31
|
+
desc=${line#*$'\0'}
|
|
32
|
+
desc=${desc%%$'\0'*}
|
|
33
|
+
|
|
34
|
+
if [[ "$value" == __FILE__:* ]]; then
|
|
35
|
+
# Parse file completion directive: __FILE__:type:extensions:pattern:hidden
|
|
36
|
+
local type extensions pattern hidden
|
|
37
|
+
IFS=':' read -r _ type extensions pattern hidden <<< "$value"
|
|
38
|
+
pattern="${pattern//%3A/:}"; pattern="${pattern//%25/%}"
|
|
39
|
+
has_file_completion=1
|
|
40
|
+
|
|
41
|
+
# Native completion helpers expect normal zsh glob grouping even if
|
|
42
|
+
# the caller enabled SH_GLOB in their shell options.
|
|
43
|
+
local __was_sh_glob=0
|
|
44
|
+
[[ -o sh_glob ]] && __was_sh_glob=1
|
|
45
|
+
unsetopt sh_glob
|
|
46
|
+
|
|
47
|
+
# Enable glob_dots when hidden files are requested so that
|
|
48
|
+
# _files and _directories include dot-prefixed entries
|
|
49
|
+
local __was_glob_dots=0
|
|
50
|
+
[[ -o glob_dots ]] && __was_glob_dots=1
|
|
51
|
+
if [[ "$hidden" == "1" ]]; then setopt glob_dots; fi
|
|
52
|
+
|
|
53
|
+
# When a pattern is specified, override PREFIX so that _files and
|
|
54
|
+
# _directories enumerate the pattern's directory instead of the
|
|
55
|
+
# current word. If the user has already typed beyond the pattern,
|
|
56
|
+
# keep PREFIX unchanged for incremental narrowing.
|
|
57
|
+
local __saved_prefix="$PREFIX"
|
|
58
|
+
if [[ -n "$pattern" ]]; then
|
|
59
|
+
# Normalize leading ./ so that ./src/ma matches pattern src/
|
|
60
|
+
local __norm_prefix="${PREFIX#./}"
|
|
61
|
+
local __norm_pattern="${pattern#./}"
|
|
62
|
+
local __compare_pattern="$__norm_pattern"
|
|
63
|
+
if [[ "$__compare_pattern" == *[*?]* ]]; then
|
|
64
|
+
__compare_pattern="${__compare_pattern%%[*?]*}"
|
|
65
|
+
[[ "$__compare_pattern" == */* ]] && __compare_pattern="${__compare_pattern%/*}/" || __compare_pattern=""
|
|
66
|
+
fi
|
|
67
|
+
if [[ ( -n "$__compare_pattern" || -n "$__norm_prefix" ) && ${#__norm_prefix} -ge ${#__compare_pattern} && "${__norm_prefix[1,${#__compare_pattern}]}" == "$__compare_pattern" && "$PREFIX" != "$pattern" ]]; then
|
|
68
|
+
# User typed an equivalent or extended form—keep PREFIX
|
|
69
|
+
true
|
|
70
|
+
else
|
|
71
|
+
PREFIX="$pattern"
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
local ext_pattern=""
|
|
76
|
+
if [[ -n "$extensions" ]]; then
|
|
77
|
+
if [[ "$extensions" == *,* ]]; then
|
|
78
|
+
ext_pattern="*.(${extensions//,/|})"
|
|
79
|
+
else
|
|
80
|
+
ext_pattern="*.$extensions"
|
|
81
|
+
fi
|
|
82
|
+
fi
|
|
83
|
+
# Use zsh's native file completion
|
|
84
|
+
case "$type" in
|
|
85
|
+
file)
|
|
86
|
+
if [[ -n "$ext_pattern" ]]; then
|
|
87
|
+
# Route filtered files through zsh's standard files/directories
|
|
88
|
+
# tags so files-tag styles and tag-order still apply, while
|
|
89
|
+
# avoiding _files' all-files fallback for extension-filtered
|
|
90
|
+
# matches.
|
|
91
|
+
local file_pattern="${ext_pattern}(#q-.)"
|
|
92
|
+
_wanted files expl file _path_files -g "${file_pattern}"
|
|
93
|
+
_wanted directories expl directory _path_files -/
|
|
94
|
+
else
|
|
95
|
+
_files
|
|
96
|
+
fi
|
|
97
|
+
;;
|
|
98
|
+
directory)
|
|
99
|
+
_directories
|
|
100
|
+
;;
|
|
101
|
+
any)
|
|
102
|
+
if [[ -n "$ext_pattern" ]]; then
|
|
103
|
+
local file_pattern="${ext_pattern}(#q^-/)"
|
|
104
|
+
_wanted files expl file _path_files -g "${file_pattern}"
|
|
105
|
+
_wanted directories expl directory _path_files -/
|
|
106
|
+
else
|
|
107
|
+
_files
|
|
108
|
+
fi
|
|
109
|
+
;;
|
|
110
|
+
esac
|
|
111
|
+
|
|
112
|
+
# Restore PREFIX and glob_dots to their previous state
|
|
113
|
+
PREFIX="$__saved_prefix"
|
|
114
|
+
if [[ "$__was_sh_glob" == "1" ]]; then setopt sh_glob; else unsetopt sh_glob; fi
|
|
115
|
+
if [[ "$__was_glob_dots" == "1" ]]; then setopt glob_dots; else unsetopt glob_dots; fi
|
|
116
|
+
else
|
|
117
|
+
# Regular literal completion
|
|
118
|
+
if [[ -n "$value" ]]; then
|
|
119
|
+
completions+=("$value")
|
|
120
|
+
descriptions+=("$desc")
|
|
121
|
+
fi
|
|
122
|
+
fi
|
|
123
|
+
fi
|
|
124
|
+
done <<< "$output"
|
|
125
|
+
|
|
126
|
+
# Add literal completions with descriptions if we have any
|
|
127
|
+
if (( ${#completions[@]} > 0 )); then
|
|
128
|
+
# Prepare completion with descriptions for _describe
|
|
129
|
+
local -a matches
|
|
130
|
+
local -i i
|
|
131
|
+
for (( i=1; i <= ${#completions[@]}; i++ )); do
|
|
132
|
+
if [[ -n "${descriptions[i]}" ]]; then
|
|
133
|
+
matches+=("${completions[i]}:${descriptions[i]}")
|
|
134
|
+
else
|
|
135
|
+
matches+=("${completions[i]}")
|
|
136
|
+
fi
|
|
137
|
+
done
|
|
138
|
+
_describe 'commands' matches
|
|
139
|
+
fi
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (( $+functions[compdef] )); then
|
|
143
|
+
compdef _drfed_migrate drfed-migrate
|
|
144
|
+
fi
|
|
145
|
+
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#compdef drfed-server
|
|
2
|
+
function _drfed_server () {
|
|
3
|
+
local current="$words[CURRENT]"
|
|
4
|
+
local -a prev
|
|
5
|
+
# Extract previous arguments, skipping empty ones
|
|
6
|
+
prev=()
|
|
7
|
+
local i
|
|
8
|
+
for (( i=2; i < CURRENT; i++ )); do
|
|
9
|
+
if [[ -n "$words[i]" ]]; then
|
|
10
|
+
prev+=("$words[i]")
|
|
11
|
+
fi
|
|
12
|
+
done
|
|
13
|
+
|
|
14
|
+
# Call the completion function and capture output
|
|
15
|
+
local output
|
|
16
|
+
if (( ${#prev[@]} == 0 )); then
|
|
17
|
+
output=$(drfed-server 'completion' 'zsh' "$current" 2>/dev/null)
|
|
18
|
+
else
|
|
19
|
+
output=$(drfed-server 'completion' 'zsh' "${prev[@]}" "$current" 2>/dev/null)
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# Split output into lines and process each line
|
|
23
|
+
local -a completions descriptions
|
|
24
|
+
local line value desc
|
|
25
|
+
local has_file_completion=0
|
|
26
|
+
|
|
27
|
+
while IFS= read -r line; do
|
|
28
|
+
if [[ -n "$line" ]]; then
|
|
29
|
+
# Split by null character - first part is value, second is description
|
|
30
|
+
value=${line%%$'\0'*}
|
|
31
|
+
desc=${line#*$'\0'}
|
|
32
|
+
desc=${desc%%$'\0'*}
|
|
33
|
+
|
|
34
|
+
if [[ "$value" == __FILE__:* ]]; then
|
|
35
|
+
# Parse file completion directive: __FILE__:type:extensions:pattern:hidden
|
|
36
|
+
local type extensions pattern hidden
|
|
37
|
+
IFS=':' read -r _ type extensions pattern hidden <<< "$value"
|
|
38
|
+
pattern="${pattern//%3A/:}"; pattern="${pattern//%25/%}"
|
|
39
|
+
has_file_completion=1
|
|
40
|
+
|
|
41
|
+
# Native completion helpers expect normal zsh glob grouping even if
|
|
42
|
+
# the caller enabled SH_GLOB in their shell options.
|
|
43
|
+
local __was_sh_glob=0
|
|
44
|
+
[[ -o sh_glob ]] && __was_sh_glob=1
|
|
45
|
+
unsetopt sh_glob
|
|
46
|
+
|
|
47
|
+
# Enable glob_dots when hidden files are requested so that
|
|
48
|
+
# _files and _directories include dot-prefixed entries
|
|
49
|
+
local __was_glob_dots=0
|
|
50
|
+
[[ -o glob_dots ]] && __was_glob_dots=1
|
|
51
|
+
if [[ "$hidden" == "1" ]]; then setopt glob_dots; fi
|
|
52
|
+
|
|
53
|
+
# When a pattern is specified, override PREFIX so that _files and
|
|
54
|
+
# _directories enumerate the pattern's directory instead of the
|
|
55
|
+
# current word. If the user has already typed beyond the pattern,
|
|
56
|
+
# keep PREFIX unchanged for incremental narrowing.
|
|
57
|
+
local __saved_prefix="$PREFIX"
|
|
58
|
+
if [[ -n "$pattern" ]]; then
|
|
59
|
+
# Normalize leading ./ so that ./src/ma matches pattern src/
|
|
60
|
+
local __norm_prefix="${PREFIX#./}"
|
|
61
|
+
local __norm_pattern="${pattern#./}"
|
|
62
|
+
local __compare_pattern="$__norm_pattern"
|
|
63
|
+
if [[ "$__compare_pattern" == *[*?]* ]]; then
|
|
64
|
+
__compare_pattern="${__compare_pattern%%[*?]*}"
|
|
65
|
+
[[ "$__compare_pattern" == */* ]] && __compare_pattern="${__compare_pattern%/*}/" || __compare_pattern=""
|
|
66
|
+
fi
|
|
67
|
+
if [[ ( -n "$__compare_pattern" || -n "$__norm_prefix" ) && ${#__norm_prefix} -ge ${#__compare_pattern} && "${__norm_prefix[1,${#__compare_pattern}]}" == "$__compare_pattern" && "$PREFIX" != "$pattern" ]]; then
|
|
68
|
+
# User typed an equivalent or extended form—keep PREFIX
|
|
69
|
+
true
|
|
70
|
+
else
|
|
71
|
+
PREFIX="$pattern"
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
local ext_pattern=""
|
|
76
|
+
if [[ -n "$extensions" ]]; then
|
|
77
|
+
if [[ "$extensions" == *,* ]]; then
|
|
78
|
+
ext_pattern="*.(${extensions//,/|})"
|
|
79
|
+
else
|
|
80
|
+
ext_pattern="*.$extensions"
|
|
81
|
+
fi
|
|
82
|
+
fi
|
|
83
|
+
# Use zsh's native file completion
|
|
84
|
+
case "$type" in
|
|
85
|
+
file)
|
|
86
|
+
if [[ -n "$ext_pattern" ]]; then
|
|
87
|
+
# Route filtered files through zsh's standard files/directories
|
|
88
|
+
# tags so files-tag styles and tag-order still apply, while
|
|
89
|
+
# avoiding _files' all-files fallback for extension-filtered
|
|
90
|
+
# matches.
|
|
91
|
+
local file_pattern="${ext_pattern}(#q-.)"
|
|
92
|
+
_wanted files expl file _path_files -g "${file_pattern}"
|
|
93
|
+
_wanted directories expl directory _path_files -/
|
|
94
|
+
else
|
|
95
|
+
_files
|
|
96
|
+
fi
|
|
97
|
+
;;
|
|
98
|
+
directory)
|
|
99
|
+
_directories
|
|
100
|
+
;;
|
|
101
|
+
any)
|
|
102
|
+
if [[ -n "$ext_pattern" ]]; then
|
|
103
|
+
local file_pattern="${ext_pattern}(#q^-/)"
|
|
104
|
+
_wanted files expl file _path_files -g "${file_pattern}"
|
|
105
|
+
_wanted directories expl directory _path_files -/
|
|
106
|
+
else
|
|
107
|
+
_files
|
|
108
|
+
fi
|
|
109
|
+
;;
|
|
110
|
+
esac
|
|
111
|
+
|
|
112
|
+
# Restore PREFIX and glob_dots to their previous state
|
|
113
|
+
PREFIX="$__saved_prefix"
|
|
114
|
+
if [[ "$__was_sh_glob" == "1" ]]; then setopt sh_glob; else unsetopt sh_glob; fi
|
|
115
|
+
if [[ "$__was_glob_dots" == "1" ]]; then setopt glob_dots; else unsetopt glob_dots; fi
|
|
116
|
+
else
|
|
117
|
+
# Regular literal completion
|
|
118
|
+
if [[ -n "$value" ]]; then
|
|
119
|
+
completions+=("$value")
|
|
120
|
+
descriptions+=("$desc")
|
|
121
|
+
fi
|
|
122
|
+
fi
|
|
123
|
+
fi
|
|
124
|
+
done <<< "$output"
|
|
125
|
+
|
|
126
|
+
# Add literal completions with descriptions if we have any
|
|
127
|
+
if (( ${#completions[@]} > 0 )); then
|
|
128
|
+
# Prepare completion with descriptions for _describe
|
|
129
|
+
local -a matches
|
|
130
|
+
local -i i
|
|
131
|
+
for (( i=1; i <= ${#completions[@]}; i++ )); do
|
|
132
|
+
if [[ -n "${descriptions[i]}" ]]; then
|
|
133
|
+
matches+=("${completions[i]}:${descriptions[i]}")
|
|
134
|
+
else
|
|
135
|
+
matches+=("${completions[i]}")
|
|
136
|
+
fi
|
|
137
|
+
done
|
|
138
|
+
_describe 'commands' matches
|
|
139
|
+
fi
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (( $+functions[compdef] )); then
|
|
143
|
+
compdef _drfed_server drfed-server
|
|
144
|
+
fi
|
|
145
|
+
|