File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ package scrcpy
2
+
3
+ import (
4
+ "regexp"
5
+ "strings"
6
+
7
+ "github.com/carapace-sh/carapace"
8
+ "github.com/carapace-sh/carapace/pkg/style"
9
+ )
10
+
11
+ // ActionApps completes apps
12
+ //
13
+ // com.github.android (GitHub)
14
+ // com.github.rsteube.t4 (T4 Launcher)
15
+ func ActionApps () carapace.Action {
16
+ return carapace .ActionExecCommand ("scrcpy" , "--list-apps" )(func (output []byte ) carapace.Action {
17
+ lines := strings .Split (string (output ), "\n " )
18
+ r := regexp .MustCompile (`^ (?P<type>[-*]) (?P<name>.+) +(?P<id>.+)$` )
19
+
20
+ vals := make ([]string , 0 )
21
+ for _ , line := range lines {
22
+ if matches := r .FindStringSubmatch (line ); matches != nil {
23
+ switch matches [1 ] {
24
+ case "-" :
25
+ vals = append (vals , matches [3 ], matches [2 ], style .Default )
26
+ case "*" :
27
+ vals = append (vals , matches [3 ], matches [2 ], style .Yellow )
28
+ }
29
+ }
30
+ }
31
+ return carapace .ActionStyledValuesDescribed (vals ... )
32
+ }).Tag ("apps" )
33
+ }
You can’t perform that action at this time.
0 commit comments