-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create main.go For run0 completer * Create root.go For run0 completer * run0: repeatable flags, chdir, and background --------- Co-authored-by: rsteube <[email protected]>
- Loading branch information
1 parent
86b7733
commit ad936b8
Showing
6 changed files
with
448 additions
and
295 deletions.
There are no files selected for viewing
This file contains 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,65 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/color" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/os" | ||
"github.com/carapace-sh/carapace-bridge/pkg/actions/bridge" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "run0", | ||
Short: "Elevate privileges interactively", | ||
Long: "https://www.man7.org/linux/man-pages/man1/run0.1.html", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
|
||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
rootCmd.Flags().SetInterspersed(false) | ||
|
||
rootCmd.Flags().String("background", "", "Set ANSI color for background") | ||
rootCmd.Flags().StringP("chdir", "D", "", "Set working directory") | ||
rootCmd.Flags().String("description", "", "Description for unit") | ||
rootCmd.Flags().StringP("group", "g", "", "Run as system group") | ||
rootCmd.Flags().BoolP("help", "h", false, "Show this help") | ||
rootCmd.Flags().String("machine", "", "Operate on local container") | ||
rootCmd.Flags().String("nice", "", "Nice level") | ||
rootCmd.Flags().Bool("no-ask-password", false, "Do not prompt for password") | ||
rootCmd.Flags().StringSlice("property", nil, "Set service or scope unit property") | ||
rootCmd.Flags().StringSlice("setenv", nil, "Set environment variable") | ||
rootCmd.Flags().String("slice", "", "Run in the specified slice") | ||
rootCmd.Flags().Bool("slice-inherit", false, "Inherit the slice") | ||
rootCmd.Flags().String("unit", "", "Run under the specified unit name") | ||
rootCmd.Flags().StringP("user", "u", "", "Run as system user") | ||
rootCmd.Flags().BoolP("version", "V", false, "Show package version") | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"background": color.ActionAnsiBackgroundColors(false), | ||
"chdir": carapace.ActionDirectories(), | ||
"group": os.ActionGroups(), | ||
"setenv": os.ActionEnvironmentVariables(), | ||
"user": os.ActionUsers(), | ||
}) | ||
|
||
carapace.Gen(rootCmd).PositionalCompletion( | ||
carapace.Batch( | ||
carapace.ActionExecutables(), | ||
carapace.ActionFiles(), | ||
).ToA(), | ||
) | ||
|
||
carapace.Gen(rootCmd).PositionalAnyCompletion( | ||
bridge.ActionCarapaceBin(), | ||
) | ||
|
||
carapace.Gen(rootCmd).PreInvoke(func(cmd *cobra.Command, flag *pflag.Flag, action carapace.Action) carapace.Action { | ||
return action.Chdir(cmd.Flag("chdir").Value.String()) | ||
}) | ||
} |
This file contains 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,7 @@ | ||
package main | ||
|
||
import "github.com/carapace-sh/carapace-bin/completers/run0_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
This file contains 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,273 @@ | ||
package color | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace/pkg/style" | ||
) | ||
|
||
// Action256Colors completes 256 colors | ||
// | ||
// 10 (Grey (SYSTEM)) | ||
// 100 (MediumPurple3) | ||
func Action256Colors() carapace.Action { | ||
return carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.ActionStyledValuesDescribed( | ||
"0", "Black (SYSTEM)", style.XTerm256Color(0), | ||
"1", "Maroon (SYSTEM)", style.XTerm256Color(1), | ||
"2", "Green (SYSTEM)", style.XTerm256Color(2), | ||
"3", "Olive (SYSTEM)", style.XTerm256Color(3), | ||
"4", "Navy (SYSTEM)", style.XTerm256Color(4), | ||
"5", "Purple (SYSTEM)", style.XTerm256Color(5), | ||
"6", "Teal (SYSTEM)", style.XTerm256Color(6), | ||
"7", "Silver (SYSTEM)", style.XTerm256Color(7), | ||
"8", "Grey (SYSTEM)", style.XTerm256Color(8), | ||
"9", "Red (SYSTEM)", style.XTerm256Color(9), | ||
"10", "Lime (SYSTEM)", style.XTerm256Color(10), | ||
"11", "Yellow (SYSTEM)", style.XTerm256Color(11), | ||
"12", "Blue (SYSTEM)", style.XTerm256Color(12), | ||
"13", "Fuchsia (SYSTEM)", style.XTerm256Color(13), | ||
"14", "Aqua (SYSTEM)", style.XTerm256Color(14), | ||
"15", "White (SYSTEM)", style.XTerm256Color(15), | ||
"16", "Grey0", style.XTerm256Color(16), | ||
"17", "NavyBlue", style.XTerm256Color(17), | ||
"18", "DarkBlue", style.XTerm256Color(18), | ||
"19", "Blue3", style.XTerm256Color(19), | ||
"20", "Blue3", style.XTerm256Color(20), | ||
"21", "Blue1", style.XTerm256Color(21), | ||
"22", "DarkGreen", style.XTerm256Color(22), | ||
"23", "DeepSkyBlue4", style.XTerm256Color(23), | ||
"24", "DeepSkyBlue4", style.XTerm256Color(24), | ||
"25", "DeepSkyBlue4", style.XTerm256Color(25), | ||
"26", "DodgerBlue3", style.XTerm256Color(26), | ||
"27", "DodgerBlue2", style.XTerm256Color(27), | ||
"28", "Green4", style.XTerm256Color(28), | ||
"29", "SpringGreen4", style.XTerm256Color(29), | ||
"30", "Turquoise4", style.XTerm256Color(30), | ||
"31", "DeepSkyBlue3", style.XTerm256Color(31), | ||
"32", "DeepSkyBlue3", style.XTerm256Color(32), | ||
"33", "DodgerBlue1", style.XTerm256Color(33), | ||
"34", "Green3", style.XTerm256Color(34), | ||
"35", "SpringGreen3", style.XTerm256Color(35), | ||
"36", "DarkCyan", style.XTerm256Color(36), | ||
"37", "LightSeaGreen", style.XTerm256Color(37), | ||
"38", "DeepSkyBlue2", style.XTerm256Color(38), | ||
"39", "DeepSkyBlue1", style.XTerm256Color(39), | ||
"40", "Green3", style.XTerm256Color(40), | ||
"41", "SpringGreen3", style.XTerm256Color(41), | ||
"42", "SpringGreen2", style.XTerm256Color(42), | ||
"43", "Cyan3", style.XTerm256Color(43), | ||
"44", "DarkTurquoise", style.XTerm256Color(44), | ||
"45", "Turquoise2", style.XTerm256Color(45), | ||
"46", "Green1", style.XTerm256Color(46), | ||
"47", "SpringGreen2", style.XTerm256Color(47), | ||
"48", "SpringGreen1", style.XTerm256Color(48), | ||
"49", "MediumSpringGreen", style.XTerm256Color(49), | ||
"50", "Cyan2", style.XTerm256Color(50), | ||
"51", "Cyan1", style.XTerm256Color(51), | ||
"52", "DarkRed", style.XTerm256Color(52), | ||
"53", "DeepPink4", style.XTerm256Color(53), | ||
"54", "Purple4", style.XTerm256Color(54), | ||
"55", "Purple4", style.XTerm256Color(55), | ||
"56", "Purple3", style.XTerm256Color(56), | ||
"57", "BlueViolet", style.XTerm256Color(57), | ||
"58", "Orange4", style.XTerm256Color(58), | ||
"59", "Grey37", style.XTerm256Color(59), | ||
"60", "MediumPurple4", style.XTerm256Color(60), | ||
"61", "SlateBlue3", style.XTerm256Color(61), | ||
"62", "SlateBlue3", style.XTerm256Color(62), | ||
"63", "RoyalBlue1", style.XTerm256Color(63), | ||
"64", "Chartreuse4", style.XTerm256Color(64), | ||
"65", "DarkSeaGreen4", style.XTerm256Color(65), | ||
"66", "PaleTurquoise4", style.XTerm256Color(66), | ||
"67", "SteelBlue", style.XTerm256Color(67), | ||
"68", "SteelBlue3", style.XTerm256Color(68), | ||
"69", "CornflowerBlue", style.XTerm256Color(69), | ||
"70", "Chartreuse3", style.XTerm256Color(70), | ||
"71", "DarkSeaGreen4", style.XTerm256Color(71), | ||
"72", "CadetBlue", style.XTerm256Color(72), | ||
"73", "CadetBlue", style.XTerm256Color(73), | ||
"74", "SkyBlue3", style.XTerm256Color(74), | ||
"75", "SteelBlue1", style.XTerm256Color(75), | ||
"76", "Chartreuse3", style.XTerm256Color(76), | ||
"77", "PaleGreen3", style.XTerm256Color(77), | ||
"78", "SeaGreen3", style.XTerm256Color(78), | ||
"79", "Aquamarine3", style.XTerm256Color(79), | ||
"80", "MediumTurquoise", style.XTerm256Color(80), | ||
"81", "SteelBlue1", style.XTerm256Color(81), | ||
"82", "Chartreuse2", style.XTerm256Color(82), | ||
"83", "SeaGreen2", style.XTerm256Color(83), | ||
"84", "SeaGreen1", style.XTerm256Color(84), | ||
"85", "SeaGreen1", style.XTerm256Color(85), | ||
"86", "Aquamarine1", style.XTerm256Color(86), | ||
"87", "DarkSlateGray2", style.XTerm256Color(87), | ||
"88", "DarkRed", style.XTerm256Color(88), | ||
"89", "DeepPink4", style.XTerm256Color(89), | ||
"90", "DarkMagenta", style.XTerm256Color(90), | ||
"91", "DarkMagenta", style.XTerm256Color(91), | ||
"92", "DarkViolet", style.XTerm256Color(92), | ||
"93", "Purple", style.XTerm256Color(93), | ||
"94", "Orange4", style.XTerm256Color(94), | ||
"95", "LightPink4", style.XTerm256Color(95), | ||
"96", "Plum4", style.XTerm256Color(96), | ||
"97", "MediumPurple3", style.XTerm256Color(97), | ||
"98", "MediumPurple3", style.XTerm256Color(98), | ||
"99", "SlateBlue1", style.XTerm256Color(99), | ||
"100", "Yellow4", style.XTerm256Color(100), | ||
"101", "Wheat4", style.XTerm256Color(101), | ||
"102", "Grey53", style.XTerm256Color(102), | ||
"103", "LightSlateGrey", style.XTerm256Color(103), | ||
"104", "MediumPurple", style.XTerm256Color(104), | ||
"105", "LightSlateBlue", style.XTerm256Color(105), | ||
"106", "Yellow4", style.XTerm256Color(106), | ||
"107", "DarkOliveGreen3", style.XTerm256Color(107), | ||
"108", "DarkSeaGreen", style.XTerm256Color(108), | ||
"109", "LightSkyBlue3", style.XTerm256Color(109), | ||
"110", "LightSkyBlue3", style.XTerm256Color(110), | ||
"111", "SkyBlue2", style.XTerm256Color(111), | ||
"112", "Chartreuse2", style.XTerm256Color(112), | ||
"113", "DarkOliveGreen3", style.XTerm256Color(113), | ||
"114", "PaleGreen3", style.XTerm256Color(114), | ||
"115", "DarkSeaGreen3", style.XTerm256Color(115), | ||
"116", "DarkSlateGray3", style.XTerm256Color(116), | ||
"117", "SkyBlue1", style.XTerm256Color(117), | ||
"118", "Chartreuse1", style.XTerm256Color(118), | ||
"119", "LightGreen", style.XTerm256Color(119), | ||
"120", "LightGreen", style.XTerm256Color(120), | ||
"121", "PaleGreen1", style.XTerm256Color(121), | ||
"122", "Aquamarine1", style.XTerm256Color(122), | ||
"123", "DarkSlateGray1", style.XTerm256Color(123), | ||
"124", "Red3", style.XTerm256Color(124), | ||
"125", "DeepPink4", style.XTerm256Color(125), | ||
"126", "MediumVioletRed", style.XTerm256Color(126), | ||
"127", "Magenta3", style.XTerm256Color(127), | ||
"128", "DarkViolet", style.XTerm256Color(128), | ||
"129", "Purple", style.XTerm256Color(129), | ||
"130", "DarkOrange3", style.XTerm256Color(130), | ||
"131", "IndianRed", style.XTerm256Color(131), | ||
"132", "HotPink3", style.XTerm256Color(132), | ||
"133", "MediumOrchid3", style.XTerm256Color(133), | ||
"134", "MediumOrchid", style.XTerm256Color(134), | ||
"135", "MediumPurple2", style.XTerm256Color(135), | ||
"136", "DarkGoldenrod", style.XTerm256Color(136), | ||
"137", "LightSalmon3", style.XTerm256Color(137), | ||
"138", "RosyBrown", style.XTerm256Color(138), | ||
"139", "Grey63", style.XTerm256Color(139), | ||
"140", "MediumPurple2", style.XTerm256Color(140), | ||
"141", "MediumPurple1", style.XTerm256Color(141), | ||
"142", "Gold3", style.XTerm256Color(142), | ||
"143", "DarkKhaki", style.XTerm256Color(143), | ||
"144", "NavajoWhite3", style.XTerm256Color(144), | ||
"145", "Grey69", style.XTerm256Color(145), | ||
"146", "LightSteelBlue3", style.XTerm256Color(146), | ||
"147", "LightSteelBlue", style.XTerm256Color(147), | ||
"148", "Yellow3", style.XTerm256Color(148), | ||
"149", "DarkOliveGreen3", style.XTerm256Color(149), | ||
"150", "DarkSeaGreen3", style.XTerm256Color(150), | ||
"151", "DarkSeaGreen2", style.XTerm256Color(151), | ||
"152", "LightCyan3", style.XTerm256Color(152), | ||
"153", "LightSkyBlue1", style.XTerm256Color(153), | ||
"154", "GreenYellow", style.XTerm256Color(154), | ||
"155", "DarkOliveGreen2", style.XTerm256Color(155), | ||
"156", "PaleGreen1", style.XTerm256Color(156), | ||
"157", "DarkSeaGreen2", style.XTerm256Color(157), | ||
"158", "DarkSeaGreen1", style.XTerm256Color(158), | ||
"159", "PaleTurquoise1", style.XTerm256Color(159), | ||
"160", "Red3", style.XTerm256Color(160), | ||
"161", "DeepPink3", style.XTerm256Color(161), | ||
"162", "DeepPink3", style.XTerm256Color(162), | ||
"163", "Magenta3", style.XTerm256Color(163), | ||
"164", "Magenta3", style.XTerm256Color(164), | ||
"165", "Magenta2", style.XTerm256Color(165), | ||
"166", "DarkOrange3", style.XTerm256Color(166), | ||
"167", "IndianRed", style.XTerm256Color(167), | ||
"168", "HotPink3", style.XTerm256Color(168), | ||
"169", "HotPink2", style.XTerm256Color(169), | ||
"170", "Orchid", style.XTerm256Color(170), | ||
"171", "MediumOrchid1", style.XTerm256Color(171), | ||
"172", "Orange3", style.XTerm256Color(172), | ||
"173", "LightSalmon3", style.XTerm256Color(173), | ||
"174", "LightPink3", style.XTerm256Color(174), | ||
"175", "Pink3", style.XTerm256Color(175), | ||
"176", "Plum3", style.XTerm256Color(176), | ||
"177", "Violet", style.XTerm256Color(177), | ||
"178", "Gold3", style.XTerm256Color(178), | ||
"179", "LightGoldenrod3", style.XTerm256Color(179), | ||
"180", "Tan", style.XTerm256Color(180), | ||
"181", "MistyRose3", style.XTerm256Color(181), | ||
"182", "Thistle3", style.XTerm256Color(182), | ||
"183", "Plum2", style.XTerm256Color(183), | ||
"184", "Yellow3", style.XTerm256Color(184), | ||
"185", "Khaki3", style.XTerm256Color(185), | ||
"186", "LightGoldenrod2", style.XTerm256Color(186), | ||
"187", "LightYellow3", style.XTerm256Color(187), | ||
"188", "Grey84", style.XTerm256Color(188), | ||
"189", "LightSteelBlue1", style.XTerm256Color(189), | ||
"190", "Yellow2", style.XTerm256Color(190), | ||
"191", "DarkOliveGreen1", style.XTerm256Color(191), | ||
"192", "DarkOliveGreen1", style.XTerm256Color(192), | ||
"193", "DarkSeaGreen1", style.XTerm256Color(193), | ||
"194", "Honeydew2", style.XTerm256Color(194), | ||
"195", "LightCyan1", style.XTerm256Color(195), | ||
"196", "Red1", style.XTerm256Color(196), | ||
"197", "DeepPink2", style.XTerm256Color(197), | ||
"198", "DeepPink1", style.XTerm256Color(198), | ||
"199", "DeepPink1", style.XTerm256Color(199), | ||
"200", "Magenta2", style.XTerm256Color(200), | ||
"201", "Magenta1", style.XTerm256Color(201), | ||
"202", "OrangeRed1", style.XTerm256Color(202), | ||
"203", "IndianRed1", style.XTerm256Color(203), | ||
"204", "IndianRed1", style.XTerm256Color(204), | ||
"205", "HotPink", style.XTerm256Color(205), | ||
"206", "HotPink", style.XTerm256Color(206), | ||
"207", "MediumOrchid1", style.XTerm256Color(207), | ||
"208", "DarkOrange", style.XTerm256Color(208), | ||
"209", "Salmon1", style.XTerm256Color(209), | ||
"210", "LightCoral", style.XTerm256Color(210), | ||
"211", "PaleVioletRed1", style.XTerm256Color(211), | ||
"212", "Orchid2", style.XTerm256Color(212), | ||
"213", "Orchid1", style.XTerm256Color(213), | ||
"214", "Orange1", style.XTerm256Color(214), | ||
"215", "SandyBrown", style.XTerm256Color(215), | ||
"216", "LightSalmon1", style.XTerm256Color(216), | ||
"217", "LightPink1", style.XTerm256Color(217), | ||
"218", "Pink1", style.XTerm256Color(218), | ||
"219", "Plum1", style.XTerm256Color(219), | ||
"220", "Gold1", style.XTerm256Color(220), | ||
"221", "LightGoldenrod2", style.XTerm256Color(221), | ||
"222", "LightGoldenrod2", style.XTerm256Color(222), | ||
"223", "NavajoWhite1", style.XTerm256Color(223), | ||
"224", "MistyRose1", style.XTerm256Color(224), | ||
"225", "Thistle1", style.XTerm256Color(225), | ||
"226", "Yellow1", style.XTerm256Color(226), | ||
"227", "LightGoldenrod1", style.XTerm256Color(227), | ||
"228", "Khaki1", style.XTerm256Color(228), | ||
"229", "Wheat1", style.XTerm256Color(229), | ||
"230", "Cornsilk1", style.XTerm256Color(230), | ||
"231", "Grey100", style.XTerm256Color(231), | ||
"232", "Grey3", style.XTerm256Color(232), | ||
"233", "Grey7", style.XTerm256Color(233), | ||
"234", "Grey11", style.XTerm256Color(234), | ||
"235", "Grey15", style.XTerm256Color(235), | ||
"236", "Grey19", style.XTerm256Color(236), | ||
"237", "Grey23", style.XTerm256Color(237), | ||
"238", "Grey27", style.XTerm256Color(238), | ||
"239", "Grey30", style.XTerm256Color(239), | ||
"240", "Grey35", style.XTerm256Color(240), | ||
"241", "Grey39", style.XTerm256Color(241), | ||
"242", "Grey42", style.XTerm256Color(242), | ||
"243", "Grey46", style.XTerm256Color(243), | ||
"244", "Grey50", style.XTerm256Color(244), | ||
"245", "Grey54", style.XTerm256Color(245), | ||
"246", "Grey58", style.XTerm256Color(246), | ||
"247", "Grey62", style.XTerm256Color(247), | ||
"248", "Grey66", style.XTerm256Color(248), | ||
"249", "Grey70", style.XTerm256Color(249), | ||
"250", "Grey74", style.XTerm256Color(250), | ||
"251", "Grey78", style.XTerm256Color(251), | ||
"252", "Grey82", style.XTerm256Color(252), | ||
"253", "Grey85", style.XTerm256Color(253), | ||
"254", "Grey89", style.XTerm256Color(254), | ||
"255", "Grey93", style.XTerm256Color(255), | ||
) | ||
}) | ||
} |
Oops, something went wrong.