Skip to content
This repository was archived by the owner on Mar 24, 2024. It is now read-only.

feat: info command #103

Merged
merged 2 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/core/programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
https://github.com/sharkdp/bat
aliases:
- key: catp
value: "bat -p"
value: "bat -P"
description: bat --plain for unformatted cat
- key: cat
value: "bat"
Expand Down
74 changes: 74 additions & 0 deletions internal/fleekcli/info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package fleekcli

import (
"github.com/spf13/cobra"
"github.com/ublue-os/fleek/internal/core"
"github.com/ublue-os/fleek/internal/ux"
)

func InfoCommand() *cobra.Command {
command := &cobra.Command{
Use: app.Trans("info.use"),
Short: app.Trans("info.short"),
Long: app.Trans("info.long"),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return infoFleek(cmd, args)
},
}
return command
}

// initCmd represents the init command
func infoFleek(cmd *cobra.Command, args []string) error {

ux.Description.Println(cmd.Short)
var b *core.Bling
var err error
switch f.config.Bling {
case "high":
b, err = core.HighBling()
cobra.CheckErr(err)
case "default":
b, err = core.DefaultBling()
cobra.CheckErr(err)
case "low":
b, err = core.LowBling()
cobra.CheckErr(err)
case "none":
b, err = core.NoBling()
cobra.CheckErr(err)
}
ux.Info.Println("["+b.Name+" Bling]", b.Description)

needle := args[0]
var found bool
pkg, ok := b.PackageMap[needle]
if ok {
found = true
ux.Info.Println(" -- " + pkg.Name + " --")
ux.Description.Println(pkg.Description)
}
prog, ok := b.ProgramMap[needle]
if ok {
found = true
ux.Info.Println(" -- " + prog.Name + " --")
ux.Description.Println(prog.Description)
if len(prog.Aliases) > 0 {

ux.Info.Println(app.Trans("info.aliases"))
for _, a := range prog.Aliases {
ux.Description.Println("\t" + a.Description)
ux.Info.Println("\t\t"+a.Key+": ", a.Value)
}

}
}
if !found {
ux.Warning.Println(needle, "-", app.Trans("info.notFound"))
}
return nil
}
3 changes: 3 additions & 0 deletions internal/fleekcli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ func RootCmd() *cobra.Command {
searchCmd := SearchCommand()
searchCmd.GroupID = packageGroup.ID

infoCmd := InfoCommand()
infoCmd.GroupID = packageGroup.ID
manCmd := ManCommand()
command.AddCommand(manCmd)
command.AddCommand(showCmd)
Expand All @@ -134,6 +136,7 @@ func RootCmd() *cobra.Command {
command.AddCommand(initCmd)
command.AddCommand(ejectCmd)
command.AddCommand(searchCmd)
command.AddCommand(infoCmd)

command.AddCommand(VersionCmd())

Expand Down
8 changes: 6 additions & 2 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,9 @@ global:
packageGroup: "Package Management Commands"
gitGroup: "Repository Management Commands"
errConflict: "A package in your .fleek.yml exists in your nix profile.\nThis can happen if you manually install something with `nix profile install ...`.\nTo fix this error, run `nix profile list` and find the profile number of the offending package, then run `nix profile remomve [that number]`\nbefore running `fleek` again."


info:
use: "info"
long: "Show detailed information about a fleek installed package"
short: "Show detailed information about a fleek installed package"
notFound: "That program or package is not part of fleek's bling set."
aliases: "Provides the following shell aliases:"