Skip to content

Commit 90a7cea

Browse files
authored
Fix for Dart and Flutter commands (#1215)
Flagged the old dart completion as outdated
1 parent 00f8a98 commit 90a7cea

3 files changed

Lines changed: 110 additions & 30 deletions

File tree

custom-completions/auto-generate/completions/dart.nu

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
def "nu-complete dart commands" [] {
2+
^dart --help
3+
| lines
4+
| skip until { $in | str contains "Available commands:" }
5+
| where { $in | str starts-with " " } # Indented lines
6+
| where { |line| not ($line | str trim | str starts-with "-") } # Ignore options
7+
| each {
8+
str trim
9+
| str replace --regex '\s+' ' '
10+
| parse "{value} {description}"
11+
}
12+
| flatten
13+
| where value not-in ["pub" "create"]
14+
}
15+
16+
def "nu-complete dart pub commands" [] {
17+
^dart pub --help
18+
| lines
19+
| skip until { $in | str contains "Available subcommands:" }
20+
| where { $in | str starts-with " " }
21+
| where { |line| not ($line | str trim | str starts-with "-") }
22+
| each {
23+
str trim
24+
| str replace --regex '\s+' ' '
25+
| parse "{value} {description}"
26+
}
27+
| flatten
28+
}
29+
30+
def "nu-complete dart templates" [] {
31+
[cli console package server-shelf web]
32+
}
33+
34+
export extern "dart" [
35+
command?: string@"nu-complete dart commands"
36+
--help(-h) # Print this usage information.
37+
--verbose(-v) # Print detailed logging.
38+
--version # Print the VM version.
39+
--enable-analytics # Enable telemetry reporting.
40+
--disable-analytics # Disable telemetry reporting.
41+
--suppress-analytics # Suppress analytics reporting for the current CLI invocation.
42+
]
43+
44+
export extern "dart create" [
45+
directory: string # Output directory
46+
--template(-t): string@"nu-complete dart templates" # The project template to use
47+
--pub # Run "pub get" after creation (default)
48+
--no-pub # Do not run "pub get"
49+
--force # Force project generation, even if the target directory already exists
50+
--help(-h) # Print this usage information
51+
]
52+
53+
export extern "dart pub" [
54+
command?: string@"nu-complete dart pub commands"
55+
]

custom-completions/flutter/flutter-completions.nu

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,71 @@
1+
def "nu-complete flutter commands" [] {
2+
^flutter --help --verbose
3+
| lines
4+
| skip until { $in | str contains "Available commands:" }
5+
| where { $in | str starts-with " " } # Indented lines
6+
| where { |line| not ($line | str trim | str starts-with "-") } # Ignore options
7+
| each {
8+
str trim
9+
| str replace --regex '\s+' ' '
10+
| parse "{value} {description}"
11+
}
12+
| flatten
13+
| where value not-in ["pub" "create"]
14+
}
15+
16+
def "nu-complete pub commands" [] {
17+
^flutter pub --help
18+
| lines
19+
| skip until { $in | str contains "Available subcommands:" }
20+
| where { $in | str starts-with " " }
21+
| where { |line| not ($line | str trim | str starts-with "-") }
22+
| each {
23+
str trim
24+
| str replace --regex '\s+' ' '
25+
| parse "{value} {description}"
26+
}
27+
| flatten
28+
}
29+
30+
def "nu-complete android-languages" [] {
31+
[java kotlin]
32+
}
33+
34+
def "nu-complete project-templates" [] {
35+
[app module package package_ffi plugin plugin_ffi skeleton]
36+
}
37+
38+
def "nu-complete platforms" [] {
39+
[ios android windows linux macos web]
40+
}
41+
142
export extern "flutter" [
243
command?: string@"nu-complete flutter commands"
344
--help(-h) # Print this usage information.
445
--verbose(-v) # Noisy logging, including all shell commands executed.
5-
--device-id(-d) # Target device id or name (prefixes allowed).
46+
--device-id(-d): string # Target device id or name (prefixes allowed).
647
--version # Reports the version of this tool.
748
--enable-analytics # Enable telemetry reporting each time a flutter or dart command runs.
849
--disable-analytics # Disable telemetry reporting each time a flutter or dart command runs, until it is re-enabled.
950
--suppress-analytics # Suppress analytics reporting for the current CLI invocation.
1051
]
1152

12-
def "nu-complete flutter commands" [] {
13-
^flutter --help
14-
| into string
15-
| str replace --regex --multiline '(Manage[\s\S]*(?=Flutter SDK))' ''
16-
| lines
17-
| where { str starts-with " " }
18-
| each { str trim }
19-
| parse "{value} {description}"
20-
| str trim
21-
}
22-
2353
export extern "flutter create" [
24-
project: string # project to create
54+
output_dir: string # Output directory
55+
--pub # Run "flutter pub get" after creation (default)
56+
--no-pub # Do not run "flutter pub get"
57+
--offline # Run "flutter pub get" in offline mode
58+
--overwrite # Overwrite existing files
59+
--description: string # The description to use for your new Flutter project
60+
--org: string # The organization responsible for your new Flutter project
61+
--project-name: string # The project name for this new Flutter project
62+
--android-language(-a): string@"nu-complete android-languages" # The language to use for Android-specific code
63+
--platforms: string@"nu-complete platforms" # The platforms supported by this project
64+
--template(-t): string@"nu-complete project-templates" # Specify the type of project to create
65+
--empty(-e) # Specifies creating using an application template with a main.dart that is minimal
66+
--help(-h) # Print this usage information
2567
]
2668

2769
export extern "flutter pub" [
2870
command?: string@"nu-complete pub commands"
2971
]
30-
31-
def "nu-complete pub commands" [] {
32-
^flutter pub --help
33-
| into string
34-
| str replace --regex --multiline '(Commands[\s\S]*(?=Available subcommands))' ''
35-
| lines
36-
| where { str starts-with " " }
37-
| each { str trim }
38-
| parse "{value} {description}"
39-
| str trim
40-
}
41-

0 commit comments

Comments
 (0)