create: add --available

parent 7a57395c
...@@ -430,6 +430,10 @@ func printTree(title string, lines []string) { ...@@ -430,6 +430,10 @@ func printTree(title string, lines []string) {
func createProfile(profileName string, prof Profile, dryRun bool, res *Result) { func createProfile(profileName string, prof Profile, dryRun bool, res *Result) {
color.Green("Создаётся профиль: %s", profileName) color.Green("Создаётся профиль: %s", profileName)
if !ProfileAvailable(prof) {
color.Red("Профиль %s недоступен", profileName)
return
}
processProfile(prof, dryRun, res) processProfile(prof, dryRun, res)
} }
...@@ -481,8 +485,9 @@ func ShowProfilesInfo() { ...@@ -481,8 +485,9 @@ func ShowProfilesInfo() {
func CreateConfCommand(ctx context.Context, cmd *cli.Command) error { func CreateConfCommand(ctx context.Context, cmd *cli.Command) error {
profile := cmd.Args().Get(0) profile := cmd.Args().Get(0)
auto := cmd.Bool("auto") auto := cmd.Bool("auto")
available := cmd.Bool("available")
if profile == "" && !auto { if profile == "" && !auto && !available {
ShowProfilesInfo() ShowProfilesInfo()
return nil return nil
} }
...@@ -505,6 +510,23 @@ func CreateConfCommand(ctx context.Context, cmd *cli.Command) error { ...@@ -505,6 +510,23 @@ func CreateConfCommand(ctx context.Context, cmd *cli.Command) error {
return err return err
} }
if available {
color.Cyan("Создаём все доступные профили...\n")
for name, profile := range cfg.Profiles {
if ProfileAvailable(profile) {
res := &Result{}
createProfile(name, profile, dryRun, res)
printTree("Копируем", res.Copies)
printTree("Создаём ссылки", res.Links)
printTree("Обновляем", res.Replaced)
printTree("Создаём переменные Hyprland", res.HyprVars)
printTree("Подключаем модули Hyprland", res.HyprModules)
printTree("Синхронизируем раскладку Hyprland", res.SyncSystemLayouts)
}
}
return nil
}
mainProf, ok := cfg.Profiles[profile] mainProf, ok := cfg.Profiles[profile]
if !ok { if !ok {
color.Red("Профиль %s не найден", profile) color.Red("Профиль %s не найден", profile)
......
...@@ -20,10 +20,14 @@ func CommandList() *cli.Command { ...@@ -20,10 +20,14 @@ func CommandList() *cli.Command {
Value: false, Value: false,
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "auto", Name: "auto",
Usage: " Automatic profile selection", Usage: "Automatic profile selection",
Aliases: []string{"a"}, Value: false,
Value: false, },
&cli.BoolFlag{
Name: "available",
Usage: "available profiles selected",
Value: false,
}, },
}, },
Action: CreateConfCommand, Action: CreateConfCommand,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment