mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 14:20:44 -06:00
cli: generalize to remote flake
This commit is contained in:
parent
c3af54a9f6
commit
517958b8b3
3 changed files with 18 additions and 34 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"oizys/internal/oizys"
|
||||
)
|
||||
|
||||
|
|
|
@ -48,11 +48,8 @@ var rootCmd = &cobra.Command{
|
|||
}
|
||||
oizys.SetFlake(flake)
|
||||
oizys.SetHost(host)
|
||||
oizys.SetCache(cacheName) // TODO: move
|
||||
oizys.SetVerbose(verbose)
|
||||
oizys.SetResetCache(resetCache)
|
||||
|
||||
oizys.CheckFlake()
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
|
||||
"github.com/briandowns/spinner"
|
||||
"github.com/charmbracelet/log"
|
||||
)
|
||||
|
||||
|
@ -55,9 +54,19 @@ func New() *Oizys {
|
|||
}
|
||||
|
||||
func SetFlake(path string) {
|
||||
// Check path exists
|
||||
if path != "" {
|
||||
o.flake = path
|
||||
}
|
||||
// check local path exists
|
||||
if !strings.HasPrefix(o.flake, "github") && !strings.HasPrefix(o.flake, "git+") {
|
||||
if _, ok := os.LookupEnv("OIZYS_SKIP_CHECK"); !ok {
|
||||
if _, err := os.Stat(o.flake); errors.Is(err, fs.ErrNotExist) {
|
||||
log.Warnf("path to flake %s does not exist, using remote as fallback", o.flake)
|
||||
o.flake = "github:daylinmorgan/oizys"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetCache(name string) {
|
||||
|
@ -131,24 +140,6 @@ func Output() string {
|
|||
}
|
||||
}
|
||||
|
||||
// func (o *Oizys) Set(
|
||||
// flake, host, cache string,
|
||||
// verbose, systemPath, resetCache bool,
|
||||
// ) {
|
||||
// if host != "" {
|
||||
// o.host = host
|
||||
// }
|
||||
// if flake != "" {
|
||||
// o.flake = flake
|
||||
// }
|
||||
// if cache != "" {
|
||||
// o.cache = cache
|
||||
// }
|
||||
// o.verbose = verbose
|
||||
// o.systemPath = systemPath
|
||||
// o.resetCache = resetCache
|
||||
// }
|
||||
|
||||
func git(rest ...string) *exec.Cmd {
|
||||
args := []string{"-C", o.flake}
|
||||
args = append(args, rest...)
|
||||
|
@ -497,11 +488,6 @@ func CacheBuild(rest ...string) {
|
|||
}
|
||||
|
||||
func CheckFlake() {
|
||||
if _, ok := os.LookupEnv("OIZYS_SKIP_CHECK"); !ok {
|
||||
if _, err := os.Stat(o.flake); errors.Is(err, fs.ErrNotExist) {
|
||||
log.Fatalf("path to flake: %s does not exist", o.flake)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CI(rest ...string) {
|
||||
|
@ -511,10 +497,10 @@ func CI(rest ...string) {
|
|||
exitWithCommand(cmd)
|
||||
}
|
||||
|
||||
// TODO: deprecate
|
||||
func nixSpinner(host string) *spinner.Spinner {
|
||||
msg := fmt.Sprintf("%s %s", " evaluating derivation for:",
|
||||
lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")).Render(host),
|
||||
)
|
||||
return startSpinner(msg)
|
||||
}
|
||||
// // TODO: deprecate
|
||||
// func nixSpinner(host string) *spinner.Spinner {
|
||||
// msg := fmt.Sprintf("%s %s", " evaluating derivation for:",
|
||||
// lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")).Render(host),
|
||||
// )
|
||||
// return startSpinner(msg)
|
||||
// }
|
||||
|
|
Loading…
Reference in a new issue