first commit

This commit is contained in:
bruno 2023-07-25 14:29:22 -04:00
commit 1d46a23824
4 changed files with 84 additions and 0 deletions

0
README.md Normal file
View File

23
config.json Normal file
View File

@ -0,0 +1,23 @@
{
"apps": [
{
"name": "neovim",
"shortcuts": {
"ctrl+alt+n": "Open neovim",
"ctrl+n": "Split neovim horizontally"
}
},
{
"name": "vscode",
"shortcuts": {
"ctrl+shift+p": "Command palette"
}
},
{
"name": "Kitty",
"shortcuts": {
"ctrl+shift+e": "Open new terminal"
}
}
]
}

BIN
scut Executable file

Binary file not shown.

61
scut.go Normal file
View File

@ -0,0 +1,61 @@
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
)
type App struct {
Name string `json:"name"`
Shortcuts map[string]string `json:"shortcuts"`
}
type Config struct {
Apps []App `json:"apps"`
}
func main() {
flag.Usage = func() {
fmt.Println("")
fmt.Println("- -- - -- - -- - -- - -- - -- - -- - --")
fmt.Println("Scut-Reminder : Gestion des raccourcis")
fmt.Println("- -- - -- - -- - -- - -- - -- - -- - --")
fmt.Println("Options :")
fmt.Printf(" -c NomDuFichierConfig Utiliser ce fichier de configuration au lieu de config.json (par défaut)\n")
fmt.Printf(" -a Nom Application Afficher les raccourcis de l'application spécifiée\n")
fmt.Printf(" -h Afficher cette aide\n")
fmt.Println("")
fmt.Println("Example :")
fmt.Printf(" scut // Affiche la liste des applications\n\n")
fmt.Printf(" scut -c MaConfig.json -a \"nevim\" // Affiche liste des raccourcis de nevim de MaConfig.json \n\n")
fmt.Printf(" scut -a \"Visual Studio Code\" //Affiche liste des raccourcis de vscode \n\n")
fmt.Println("")
}
configFile := flag.String("c", "config.json", "Config file")
appName := flag.String("a", "", "Application name")
flag.Parse()
data, _ := ioutil.ReadFile(*configFile)
var config Config
json.Unmarshal(data, &config)
if *appName == "" {
// List all applications
for _, app := range config.Apps {
fmt.Printf("%s\n", app.Name)
}
} else {
// List shortcuts for application
for _, app := range config.Apps {
if app.Name == *appName {
for shortcut, desc := range app.Shortcuts {
fmt.Printf("%s: %s\n", shortcut, desc)
}
}
}
}
}