Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximperconf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximperconf
Commits
e0f51b85
Commit
e0f51b85
authored
Jan 22, 2026
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'devel' into 'master'
add json format See merge request
!2
parents
661d0a49
aa008de8
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
235 additions
and
16 deletions
+235
-16
format.go
config/format.go
+19
-0
actions.go
hyprland/actions.go
+63
-0
commands.go
hyprland/commands.go
+27
-6
json.go
hyprland/json.go
+16
-0
plugin-actions.go
hyprland/plugin-actions.go
+16
-0
var-actions.go
hyprland/var-actions.go
+19
-0
actions.go
preset/actions.go
+12
-3
commands.go
preset/commands.go
+5
-2
actions.go
repo/actions.go
+14
-2
commands.go
repo/commands.go
+10
-3
json.go
ui/json.go
+34
-0
No files found.
config/format.go
0 → 100644
View file @
e0f51b85
package
config
import
"github.com/urfave/cli/v3"
const
(
FormatText
=
"text"
FormatJSON
=
"json"
)
var
FormatFlag
=
&
cli
.
StringFlag
{
Name
:
"format"
,
Usage
:
"output format (text, json)"
,
Value
:
FormatText
,
Aliases
:
[]
string
{
"o"
},
}
func
IsJSON
(
cmd
*
cli
.
Command
)
bool
{
return
cmd
.
String
(
"format"
)
==
FormatJSON
}
hyprland/actions.go
View file @
e0f51b85
...
...
@@ -168,6 +168,9 @@ func HyprlandInfoModulesCommand(ctx context.Context, cmd *cli.Command) error {
modules
:=
manager
.
GetModulesList
(
user
,
filter
)
if
len
(
modules
)
==
0
{
if
config
.
IsJSON
(
cmd
)
{
return
ui
.
PrintJSON
([]
ui
.
JSONItem
{})
}
return
fmt
.
Errorf
(
"нет доступных модулей"
)
}
...
...
@@ -191,6 +194,10 @@ func HyprlandInfoModulesCommand(ctx context.Context, cmd *cli.Command) error {
})
}
if
config
.
IsJSON
(
cmd
)
{
return
ui
.
PrintJSON
(
ui
.
TreeItemsToJSON
(
items
))
}
ui
.
RenderTree
(
ui
.
RenderTreeOptions
{
Title
:
"Modules"
,
Items
:
items
,
...
...
@@ -235,3 +242,59 @@ func HyprlandModuleEditCommand(ctx context.Context, cmd *cli.Command) error {
return
nil
}
func
HyprlandModuleShowCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
module
:=
cmd
.
Args
()
.
Get
(
0
)
if
module
==
""
{
return
fmt
.
Errorf
(
"укажите имя модуля"
)
}
user
:=
cmd
.
Bool
(
"user"
)
manager
,
err
:=
GetHyprlandManager
(
ctx
)
if
err
!=
nil
{
return
err
}
info
:=
manager
.
GetModuleInfo
(
module
,
user
)
if
!
info
.
Available
{
return
fmt
.
Errorf
(
"недопустимое название для модуля"
)
}
errors
,
_
:=
manager
.
CheckModule
(
module
,
user
)
if
config
.
IsJSON
(
cmd
)
{
jsonErrors
:=
make
([]
ModuleErrorJSON
,
len
(
errors
))
for
i
,
e
:=
range
errors
{
jsonErrors
[
i
]
=
ModuleErrorJSON
{
Line
:
e
.
Line
,
Text
:
e
.
Text
}
}
return
ui
.
PrintJSON
(
ModuleShowJSON
{
Name
:
info
.
Name
,
Status
:
info
.
Status
.
Label
,
Path
:
info
.
Path
,
ConfPath
:
info
.
ConfPath
,
LineNumber
:
info
.
LineNumber
,
Available
:
info
.
Available
,
Errors
:
jsonErrors
,
})
}
fmt
.
Printf
(
"Модуль: %s
\n
"
,
info
.
Name
)
fmt
.
Printf
(
"Статус: %s
\n
"
,
info
.
Status
.
Color
(
"%s %s"
,
info
.
Status
.
Symbol
,
info
.
Status
.
Label
))
fmt
.
Printf
(
"Путь: %s
\n
"
,
info
.
Path
)
fmt
.
Printf
(
"Путь в конфиге: %s
\n
"
,
info
.
ConfPath
)
fmt
.
Printf
(
"Строка в конфиге: %d
\n
"
,
info
.
LineNumber
)
if
info
.
Available
{
fmt
.
Println
(
"Доступен: да"
)
}
else
{
fmt
.
Println
(
"Доступен: нет"
)
}
if
len
(
errors
)
>
0
{
fmt
.
Printf
(
"
\n
Ошибки (%d):
\n
"
,
len
(
errors
))
for
_
,
e
:=
range
errors
{
fmt
.
Printf
(
" %d: %s
\n
"
,
e
.
Line
,
e
.
Text
)
}
}
return
nil
}
hyprland/commands.go
View file @
e0f51b85
...
...
@@ -83,6 +83,16 @@ func CommandList() *cli.Command {
ShellComplete
:
ShellCompleteModule
(
"all"
),
},
{
Name
:
"show"
,
Usage
:
"Show detailed module info"
,
ArgsUsage
:
"module"
,
Flags
:
[]
cli
.
Flag
{
config
.
FormatFlag
,
},
Action
:
HyprlandModuleShowCommand
,
ShellComplete
:
ShellCompleteModule
(
"all"
),
},
{
Name
:
"info"
,
Usage
:
"Information about modules"
,
Flags
:
[]
cli
.
Flag
{
...
...
@@ -92,6 +102,7 @@ func CommandList() *cli.Command {
Aliases
:
[]
string
{
"f"
},
Value
:
"all"
,
},
config
.
FormatFlag
,
},
Action
:
HyprlandInfoModulesCommand
,
},
...
...
@@ -131,13 +142,19 @@ func CommandList() *cli.Command {
Usage
:
"Hyprland vars"
,
Commands
:
[]
*
cli
.
Command
{
{
Name
:
"list"
,
Usage
:
"vars list"
,
Name
:
"list"
,
Usage
:
"vars list"
,
Flags
:
[]
cli
.
Flag
{
config
.
FormatFlag
,
},
Action
:
HyprlandVarListCommand
,
},
{
Name
:
"info"
,
Usage
:
"vars info"
,
Name
:
"info"
,
Usage
:
"vars info"
,
Flags
:
[]
cli
.
Flag
{
config
.
FormatFlag
,
},
Action
:
HyprlandVarInfoCommand
,
},
{
...
...
@@ -164,8 +181,11 @@ func CommandList() *cli.Command {
Usage
:
"Hyprland plugins"
,
Commands
:
[]
*
cli
.
Command
{
{
Name
:
"list"
,
Usage
:
"Hyprland plugins list"
,
Name
:
"list"
,
Usage
:
"Hyprland plugins list"
,
Flags
:
[]
cli
.
Flag
{
config
.
FormatFlag
,
},
Action
:
HyprlandPluginListCommand
,
},
{
...
...
@@ -185,6 +205,7 @@ func CommandList() *cli.Command {
Aliases
:
[]
string
{
"f"
},
Value
:
"all"
,
},
config
.
FormatFlag
,
},
Action
:
HyprlandPluginInfoCommand
,
},
...
...
hyprland/json.go
0 → 100644
View file @
e0f51b85
package
hyprland
type
ModuleShowJSON
struct
{
Name
string
`json:"name"`
Status
string
`json:"status"`
Path
string
`json:"path"`
ConfPath
string
`json:"conf_path"`
LineNumber
int
`json:"line_number"`
Available
bool
`json:"available"`
Errors
[]
ModuleErrorJSON
`json:"errors"`
}
type
ModuleErrorJSON
struct
{
Line
int
`json:"line"`
Text
string
`json:"text"`
}
hyprland/plugin-actions.go
View file @
e0f51b85
...
...
@@ -17,6 +17,15 @@ func HyprlandPluginListCommand(ctx context.Context, cmd *cli.Command) error {
return
err
}
list
:=
manager
.
GetPluginsList
(
cmd
.
String
(
"filter"
))
if
config
.
IsJSON
(
cmd
)
{
items
:=
make
([]
ui
.
JSONItem
,
len
(
list
))
for
i
,
name
:=
range
list
{
items
[
i
]
=
ui
.
JSONItem
{
Name
:
name
}
}
return
ui
.
PrintJSON
(
items
)
}
fmt
.
Println
(
strings
.
Join
(
list
,
"
\n
"
))
return
nil
}
...
...
@@ -37,6 +46,9 @@ func HyprlandPluginInfoCommand(ctx context.Context, cmd *cli.Command) error {
}
plugins
:=
manager
.
GetPluginsList
(
cmd
.
String
(
"filter"
))
if
len
(
plugins
)
==
0
{
if
config
.
IsJSON
(
cmd
)
{
return
ui
.
PrintJSON
([]
ui
.
JSONItem
{})
}
return
fmt
.
Errorf
(
"нет доступных плагинов"
)
}
...
...
@@ -59,6 +71,10 @@ func HyprlandPluginInfoCommand(ctx context.Context, cmd *cli.Command) error {
})
}
if
config
.
IsJSON
(
cmd
)
{
return
ui
.
PrintJSON
(
ui
.
TreeItemsToJSON
(
items
))
}
ui
.
RenderTree
(
ui
.
RenderTreeOptions
{
Title
:
"Plugins"
,
Items
:
items
,
...
...
hyprland/var-actions.go
View file @
e0f51b85
...
...
@@ -21,6 +21,14 @@ func HyprlandVarListCommand(ctx context.Context, cmd *cli.Command) error {
return
err
}
if
config
.
IsJSON
(
cmd
)
{
items
:=
make
([]
ui
.
JSONItem
,
len
(
manager
.
Vars
))
for
i
,
v
:=
range
manager
.
Vars
{
items
[
i
]
=
ui
.
JSONItem
{
Name
:
v
.
Name
,
Value
:
v
.
Value
}
}
return
ui
.
PrintJSON
(
items
)
}
for
_
,
v
:=
range
manager
.
Vars
{
fmt
.
Println
(
v
.
Name
)
}
...
...
@@ -37,6 +45,9 @@ func HyprlandVarInfoCommand(ctx context.Context, cmd *cli.Command) error {
info
:=
manager
.
GetVarList
()
if
len
(
info
)
==
0
{
if
config
.
IsJSON
(
cmd
)
{
return
ui
.
PrintJSON
([]
ui
.
JSONItem
{})
}
color
.
Yellow
(
"Нет переменных в конфигурации"
)
return
nil
}
...
...
@@ -53,6 +64,14 @@ func HyprlandVarInfoCommand(ctx context.Context, cmd *cli.Command) error {
})
}
if
config
.
IsJSON
(
cmd
)
{
jsonItems
:=
make
([]
ui
.
JSONItem
,
len
(
info
))
for
i
,
v
:=
range
info
{
jsonItems
[
i
]
=
ui
.
JSONItem
{
Name
:
v
.
Name
,
Value
:
v
.
Value
}
}
return
ui
.
PrintJSON
(
jsonItems
)
}
ui
.
RenderTree
(
ui
.
RenderTreeOptions
{
Title
:
"Vars"
,
Items
:
items
,
...
...
preset/actions.go
View file @
e0f51b85
...
...
@@ -396,10 +396,14 @@ func createProfile(profileName string, prof config.PresetProfile, dryRun bool, r
processProfile
(
prof
,
dryRun
,
res
)
}
func
ShowProfilesInfo
()
{
func
ShowProfilesInfo
(
jsonFormat
bool
)
{
profiles
:=
config
.
Env
.
Preset
.
Profiles
if
len
(
profiles
)
==
0
{
if
jsonFormat
{
ui
.
PrintJSON
([]
ui
.
JSONItem
{})
return
}
color
.
Red
(
"Нет доступных профилей"
)
return
}
...
...
@@ -416,6 +420,11 @@ func ShowProfilesInfo() {
})
}
if
jsonFormat
{
ui
.
PrintJSON
(
ui
.
TreeItemsToJSON
(
items
))
return
}
ui
.
RenderTree
(
ui
.
RenderTreeOptions
{
Title
:
"Profiles"
,
Items
:
items
,
...
...
@@ -429,7 +438,7 @@ func presetApplyCommand(ctx context.Context, cmd *cli.Command) error {
profileName
:=
cmd
.
Args
()
.
Get
(
0
)
if
profileName
==
""
{
ShowProfilesInfo
()
ShowProfilesInfo
(
false
)
return
nil
}
...
...
@@ -475,6 +484,6 @@ func presetApplyAllCommand(ctx context.Context, cmd *cli.Command) error {
}
func
presetInfoCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
ShowProfilesInfo
()
ShowProfilesInfo
(
config
.
IsJSON
(
cmd
)
)
return
nil
}
preset/commands.go
View file @
e0f51b85
...
...
@@ -14,8 +14,11 @@ func CommandList() *cli.Command {
Usage
:
"Manage preset configuration profiles"
,
Commands
:
[]
*
cli
.
Command
{
{
Name
:
"info"
,
Usage
:
"Show information about a preset profiles"
,
Name
:
"info"
,
Usage
:
"Show information about a preset profiles"
,
Flags
:
[]
cli
.
Flag
{
config
.
FormatFlag
,
},
Action
:
presetInfoCommand
,
},
{
...
...
repo/actions.go
View file @
e0f51b85
package
repo
import
(
"ximperconf/config"
"context"
"fmt"
"io"
"net/http"
"os"
"regexp"
"ximperconf/config"
"ximperconf/ui"
"github.com/fatih/color"
"github.com/urfave/cli/v3"
)
type
DeferredInfo
struct
{
LastUpdate
string
`json:"last_update"`
ArchiveDate
string
`json:"archive_date"`
}
var
(
reLastUpdate
=
regexp
.
MustCompile
(
`Last update date: ([0-9:\- ]+)`
)
reArchiveDate
=
regexp
.
MustCompile
(
`Sisyphus archive date: ([0-9\-]+)`
)
...
...
@@ -73,6 +78,13 @@ func DeferredInfoCommand(ctx context.Context, cmd *cli.Command) error {
lastUpdate
:=
deferredLastUpdate
(
html
)
archiveDate
:=
deferredArchiveDate
(
html
)
if
config
.
IsJSON
(
cmd
)
{
return
ui
.
PrintJSON
(
DeferredInfo
{
LastUpdate
:
lastUpdate
,
ArchiveDate
:
archiveDate
,
})
}
color
.
Green
(
"Deferred:"
)
fmt
.
Printf
(
" Последнее обновление: %s
\n
"
,
lastUpdate
)
fmt
.
Printf
(
" Дата архива: %s
\n
"
,
archiveDate
)
...
...
repo/commands.go
View file @
e0f51b85
package
repo
import
"github.com/urfave/cli/v3"
import
(
"ximperconf/config"
"github.com/urfave/cli/v3"
)
func
CommandList
()
*
cli
.
Command
{
return
&
cli
.
Command
{
...
...
@@ -12,8 +16,11 @@ func CommandList() *cli.Command {
Usage
:
"Deferred repo"
,
Commands
:
[]
*
cli
.
Command
{
{
Name
:
"info"
,
Usage
:
"Deferred repo info"
,
Name
:
"info"
,
Usage
:
"Deferred repo info"
,
Flags
:
[]
cli
.
Flag
{
config
.
FormatFlag
,
},
Action
:
DeferredInfoCommand
,
},
{
...
...
ui/json.go
0 → 100644
View file @
e0f51b85
package
ui
import
(
"encoding/json"
"fmt"
)
type
JSONItem
struct
{
Name
string
`json:"name"`
Status
string
`json:"status,omitempty"`
Description
string
`json:"description,omitempty"`
Value
string
`json:"value,omitempty"`
}
func
TreeItemsToJSON
(
items
[]
TreeItem
)
[]
JSONItem
{
result
:=
make
([]
JSONItem
,
len
(
items
))
for
i
,
item
:=
range
items
{
result
[
i
]
=
JSONItem
{
Name
:
item
.
Name
,
Status
:
item
.
Status
.
Label
,
Description
:
item
.
Description
,
}
}
return
result
}
func
PrintJSON
(
data
interface
{})
error
{
output
,
err
:=
json
.
MarshalIndent
(
data
,
""
,
" "
)
if
err
!=
nil
{
return
err
}
fmt
.
Println
(
string
(
output
))
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment