internal/app: declutter and merge small files
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m4s
Test / Hakurei (push) Successful in 3m2s
Test / Hpkg (push) Successful in 4m3s
Test / Hakurei (race detector) (push) Successful in 5m8s
Test / Sandbox (race detector) (push) Successful in 2m4s
Test / Flake checks (push) Successful in 1m26s
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m4s
Test / Hakurei (push) Successful in 3m2s
Test / Hpkg (push) Successful in 4m3s
Test / Hakurei (race detector) (push) Successful in 5m8s
Test / Sandbox (race detector) (push) Successful in 2m4s
Test / Flake checks (push) Successful in 1m26s
This should make internal/app easier to work with for the upcoming params to shim. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
dd0bb0a391
commit
a5f0aa3f30
@ -237,25 +237,10 @@ func buildCommand(ctx context.Context, msg container.Msg, early *earlyHardeningE
|
|||||||
}).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id")
|
}).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id")
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Command("version", "Display version information", func(args []string) error {
|
c.Command("version", "Display version information", func(args []string) error { fmt.Println(internal.Version()); return errSuccess })
|
||||||
fmt.Println(internal.Version())
|
c.Command("license", "Show full license text", func(args []string) error { fmt.Println(license); return errSuccess })
|
||||||
return errSuccess
|
c.Command("template", "Produce a config template", func(args []string) error { printJSON(os.Stdout, false, hst.Template()); return errSuccess })
|
||||||
})
|
c.Command("help", "Show this help message", func([]string) error { c.PrintHelp(); return errSuccess })
|
||||||
|
|
||||||
c.Command("license", "Show full license text", func(args []string) error {
|
|
||||||
fmt.Println(license)
|
|
||||||
return errSuccess
|
|
||||||
})
|
|
||||||
|
|
||||||
c.Command("template", "Produce a config template", func(args []string) error {
|
|
||||||
printJSON(os.Stdout, false, hst.Template())
|
|
||||||
return errSuccess
|
|
||||||
})
|
|
||||||
|
|
||||||
c.Command("help", "Show this help message", func([]string) error {
|
|
||||||
c.PrintHelp()
|
|
||||||
return errSuccess
|
|
||||||
})
|
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,17 @@ import (
|
|||||||
"hakurei.app/system/wayland"
|
"hakurei.app/system/wayland"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func newInt(v int) *stringPair[int] { return &stringPair[int]{v, strconv.Itoa(v)} }
|
||||||
|
|
||||||
|
// stringPair stores a value and its string representation.
|
||||||
|
type stringPair[T comparable] struct {
|
||||||
|
v T
|
||||||
|
s string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *stringPair[T]) unwrap() T { return s.v }
|
||||||
|
func (s *stringPair[T]) String() string { return s.s }
|
||||||
|
|
||||||
func newWithMessage(msg string) error { return newWithMessageError(msg, os.ErrInvalid) }
|
func newWithMessage(msg string) error { return newWithMessageError(msg, os.ErrInvalid) }
|
||||||
func newWithMessageError(msg string, err error) error {
|
func newWithMessageError(msg string, err error) error {
|
||||||
return &hst.AppError{Step: "finalise", Err: err, Msg: msg}
|
return &hst.AppError{Step: "finalise", Err: err, Msg: msg}
|
||||||
|
@ -6,6 +6,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func deepContainsH(basepath, targpath string) (bool, error) {
|
func deepContainsH(basepath, targpath string) (bool, error) {
|
||||||
|
const upper = ".." + string(filepath.Separator)
|
||||||
|
|
||||||
rel, err := filepath.Rel(basepath, targpath)
|
rel, err := filepath.Rel(basepath, targpath)
|
||||||
return err == nil && rel != ".." && !strings.HasPrefix(rel, string([]byte{'.', '.', filepath.Separator})), err
|
return err == nil &&
|
||||||
|
rel != ".." &&
|
||||||
|
!strings.HasPrefix(rel, upper), err
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newInt(v int) *stringPair[int] { return &stringPair[int]{v, strconv.Itoa(v)} }
|
|
||||||
|
|
||||||
// stringPair stores a value and its string representation.
|
|
||||||
type stringPair[T comparable] struct {
|
|
||||||
v T
|
|
||||||
s string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stringPair[T]) unwrap() T { return s.v }
|
|
||||||
func (s *stringPair[T]) String() string { return s.s }
|
|
Loading…
x
Reference in New Issue
Block a user