Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
proper tests, removed --test flag
Browse files Browse the repository at this point in the history
  • Loading branch information
abs3ntdev committed Jan 4, 2023
1 parent f664b55 commit 4435a78
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 63 deletions.
3 changes: 0 additions & 3 deletions flags/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

type Flags struct {
Help bool
Test bool
Json bool
Markdown bool
Raw bool
Expand All @@ -19,7 +18,6 @@ type Flags struct {

func ReadFlags() *Flags {
optHelp := getopt.BoolLong("help", 'h', "Show this help menu")
optTest := getopt.BoolLong("test", 't', "Use the test configuration file")
optJson := getopt.BoolLong("json", 'j', "Return settigns as json")
optMarkdown := getopt.BoolLong("markdown", 'm', "Print the binds as a markdown table")
optRaw := getopt.BoolLong("raw", 'r', "Print text as is, without making it pretty")
Expand All @@ -31,7 +29,6 @@ func ReadFlags() *Flags {
getopt.Parse()
return &Flags{
Help: *optHelp,
Test: *optTest,
Json: *optJson,
Markdown: *optMarkdown,
Raw: *optRaw,
Expand Down
3 changes: 0 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ func main() {
if flags.ConfigPath == "" {
flags.ConfigPath = filepath.Join(os.Getenv("HOME"), ".config/hypr/hyprland.conf")
}
if flags.Test {
flags.ConfigPath = "test/hyprland.conf"
}

configValues, err := reader.ReadHyprlandConfig(flags.ConfigPath)
if err != nil {
Expand Down
54 changes: 54 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package main

import (
"testing"

// io/ioutil is deprecated, use io and os packages instead
"notashelf.dev/hyprkeys/flags"
"notashelf.dev/hyprkeys/reader"
)

func TestMarkdown(t *testing.T) {
flags := &flags.Flags{}
flags.ConfigPath = "test/hyprland.conf"
flags.Output = "test/markdown.md"
flags.Markdown = true
configValues, err := reader.ReadHyprlandConfig(flags.ConfigPath)
if err != nil {
t.Errorf(err.Error())
}
err = markdownHandler(configValues, flags)
if err != nil {
t.Errorf(err.Error())
}
}

func TestJson(t *testing.T) {
flags := &flags.Flags{}
flags.ConfigPath = "test/hyprland.conf"
flags.Output = "test/out.json"
flags.Json = true
configValues, err := reader.ReadHyprlandConfig(flags.ConfigPath)
if err != nil {
t.Errorf(err.Error())
}
err = jsonHandler(configValues, flags)
if err != nil {
t.Errorf(err.Error())
}
}

func TestRaw(t *testing.T) {
flags := &flags.Flags{}
flags.ConfigPath = "test/hyprland.conf"
flags.Output = "test/out"
flags.Json = true
configValues, err := reader.ReadHyprlandConfig(flags.ConfigPath)
if err != nil {
t.Errorf(err.Error())
}
err = rawHandler(configValues, flags)
if err != nil {
t.Errorf(err.Error())
}
}
65 changes: 8 additions & 57 deletions test/markdown.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,10 @@
# Sample Markdown

This is an example output for `hyprkeys --markdown`. Syntax is last updated on 4/1/2023.
May be subjected to change.

## Keys

| Keybind | Dispatcher | Command | Comments |
|---------|------------|---------|----------|
| <kbd>SUPER D</kbd> | exec | rofi -modi combi -combi-modi drun,window,ssh -show combi | |
| <kbd>SUPER Return</kbd> | exec | kitty | |
| <kbd>SUPER BACKSPACE</kbd> | exec | firefox-nightly | |
| <kbd>SUPER H</kbd> | exec | pcmanfm | |
| <kbd>SUPER CONTROL ALT P</kbd> | exec | spt playback -t | |
| <kbd>SUPER CONTROL ALT N</kbd> | exec | spt playback -n | |
| <kbd>SUPER CONTROL ALT H</kbd> | exec | spt playback -p | |
| <kbd>SUPER CONTROL ALT L</kbd> | exec | spt playback --like | |
| <kbd>SUPER SHIFT S</kbd> | exec | slurp -d \| grim -g - - \| wl-copy | |
| <kbd>SUPER CONTROL ALT S</kbd> | exec | grim -o DP-1 - \| wl-copy | |
| <kbd>SUPER SHIFT CONTROL S</kbd> | exec | wf-recorder -g "$(slurp)" --audio -f ~/Videos/Screenrecord/record.mp4 | |
| <kbd>SUPER SHIFT CONTROL A</kbd> | exec | killall -s SIGINT wf-recorder | |
| <kbd>SUPER SHIFT W</kbd> | exec | ~/Scripts/set_wallpaper.sh | |
| <kbd>SUPER SHIFT V</kbd> | exec | clipman pick -t rofi | |
| <kbd>SUPER ALT L</kbd> | exec | ~/Scripts/lockscreen.sh | |
| <kbd>SUPER V</kbd> | togglefloating | | |
| <kbd>SUPER F</kbd> | fullscreen | | |
| <kbd>SUPER SHIFT F</kbd> | fakefullscreen | | |
| <kbd>SUPER P</kbd> | pseudo | | dwindle |
| <kbd>SUPER J</kbd> | togglesplit | | dwindle |
| <kbd>SUPER SHIFT Q</kbd> | killactive | | |
| <kbd>SUPER left</kbd> | movefocus | l | |
| <kbd>SUPER right</kbd> | movefocus | r | |
| <kbd>SUPER up</kbd> | movefocus | u | |
| <kbd>SUPER down</kbd> | movefocus | d | |
| <kbd>SUPER 1</kbd> | workspace | 1 | |
| <kbd>SUPER 2</kbd> | workspace | 2 | |
| <kbd>SUPER 3</kbd> | workspace | 3 | |
| <kbd>SUPER 4</kbd> | workspace | 4 | |
| <kbd>SUPER 5</kbd> | workspace | 5 | |
| <kbd>SUPER 6</kbd> | workspace | 6 | |
| <kbd>SUPER 7</kbd> | workspace | 7 | |
| <kbd>SUPER 8</kbd> | workspace | 8 | |
| <kbd>SUPER 9</kbd> | workspace | 9 | |
| <kbd>SUPER 0</kbd> | workspace | 10 | |
| <kbd>SUPER SHIFT 1</kbd> | movetoworkspacesilent | 1 | |
| <kbd>SUPER SHIFT 2</kbd> | movetoworkspacesilent | 2 | |
| <kbd>SUPER SHIFT 3</kbd> | movetoworkspacesilent | 3 | |
| <kbd>SUPER SHIFT 4</kbd> | movetoworkspacesilent | 4 | |
| <kbd>SUPER SHIFT 5</kbd> | movetoworkspacesilent | 5 | |
| <kbd>SUPER SHIFT 6</kbd> | movetoworkspacesilent | 6 | |
| <kbd>SUPER SHIFT 7</kbd> | movetoworkspacesilent | 7 | |
| <kbd>SUPER SHIFT 8</kbd> | movetoworkspacesilent | 8 | |
| <kbd>SUPER SHIFT 9</kbd> | movetoworkspacesilent | 9 | |
| <kbd>SUPER SHIFT 0</kbd> | movetoworkspacesilent | 10 | |
| <kbd>SUPER mouse_down</kbd> | workspace | e+1 | |
| <kbd>SUPER mouse_up</kbd> | workspace | e-1 | |
| <kbd>SUPER SHIFT M</kbd> | exit | | |
| <kbd>SUPER mouse:272</kbd> | movewindow | |
| <kbd>SUPER mouse:273</kbd> | resizewindow | |
| <kbd>$mainMod Q</kbd> | exec | kitty | |
| <kbd>$mainMod C</kbd> | killactive | | |
| <kbd>$mainMod M</kbd> | exit | | |
| <kbd>$mainMod E</kbd> | exec | dolphin | |
| <kbd>$mainMod V</kbd> | togglefloating | | |
| <kbd>$mainMod R</kbd> | exec | wofi --show drun | |
| <kbd>$mainMod P</kbd> | pseudo | | dwindle |
| <kbd>$mainMod J</kbd> | togglesplit | | dwindle |
43 changes: 43 additions & 0 deletions test/out
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
bind = $mainMod Q exec kitty #
bind = $mainMod C killactive #
bind = $mainMod M exit #
bind = $mainMod E exec dolphin #
bind = $mainMod V togglefloating #
bind = $mainMod R exec wofi --show drun #
bind = $mainMod P pseudo #dwindle
bind = $mainMod J togglesplit #dwindle
input {
kb_layout = us
follow_mouse = 1
sensitivity = 0#-1.0-1.0,0meansnomodification.
touchpad {
natural_scroll = no
}
}
general {
layout = dwindle
gaps_in = 5
gaps_out = 20
border_size = 2
col.active_border = rgba(1affffee)
col.inactive_border = rgba(595959aa)
}
decoration {
blur = yes
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
shadow_range = 4
rounding = 10
blur_size = 3
blur_passes = 1
blur_new_optimizations = on
drop_shadow = yes
}
animation {
enabled = yes
bezier = myBezier,0.05,0.9,0.1,1.05
animation = workspaces,1,6,default
}
gestures {
workspace_swipe = off
}
123 changes: 123 additions & 0 deletions test/out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"Settings": [
{
"Name": "input",
"Settings": {
"follow_mouse": "1",
"kb_layout": "us",
"sensitivity": "0#-1.0-1.0,0meansnomodification."
},
"SubCategories": [
{
"Name": "touchpad",
"Settings": {
"natural_scroll": "no"
},
"SubCategories": null
}
]
},
{
"Name": "general",
"Settings": {
"border_size": "2",
"col.active_border": "rgba(1affffee)",
"col.inactive_border": "rgba(595959aa)",
"gaps_in": "5",
"gaps_out": "20",
"layout": "dwindle"
},
"SubCategories": null
},
{
"Name": "decoration",
"Settings": {
"blur": "yes",
"blur_new_optimizations": "on",
"blur_passes": "1",
"blur_size": "3",
"col.shadow": "rgba(1a1a1aee)",
"drop_shadow": "yes",
"rounding": "10",
"shadow_range": "4",
"shadow_render_power": "3"
},
"SubCategories": null
},
{
"Name": "animation",
"Settings": {
"animation": "workspaces,1,6,default",
"bezier": "myBezier,0.05,0.9,0.1,1.05",
"enabled": "yes"
},
"SubCategories": null
},
{
"Name": "gestures",
"Settings": {
"workspace_swipe": "off"
},
"SubCategories": null
}
],
"KeyboardBinds": [
{
"BindType": "bind",
"Bind": "$mainMod Q",
"Dispatcher": "exec",
"Command": "kitty",
"Comments": ""
},
{
"BindType": "bind",
"Bind": "$mainMod C",
"Dispatcher": "killactive",
"Command": "",
"Comments": ""
},
{
"BindType": "bind",
"Bind": "$mainMod M",
"Dispatcher": "exit",
"Command": "",
"Comments": ""
},
{
"BindType": "bind",
"Bind": "$mainMod E",
"Dispatcher": "exec",
"Command": "dolphin",
"Comments": ""
},
{
"BindType": "bind",
"Bind": "$mainMod V",
"Dispatcher": "togglefloating",
"Command": "",
"Comments": ""
},
{
"BindType": "bind",
"Bind": "$mainMod R",
"Dispatcher": "exec",
"Command": "wofi --show drun",
"Comments": ""
},
{
"BindType": "bind",
"Bind": "$mainMod P",
"Dispatcher": "pseudo",
"Command": "",
"Comments": "dwindle"
},
{
"BindType": "bind",
"Bind": "$mainMod J",
"Dispatcher": "togglesplit",
"Command": "",
"Comments": "dwindle"
}
],
"MouseBinds": null
}

0 comments on commit 4435a78

Please sign in to comment.