2022-10-20 19:59:46 +00:00
|
|
|
package main
|
2022-10-16 15:18:50 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2023-08-05 21:53:17 +00:00
|
|
|
"isle/admin"
|
2022-10-16 15:18:50 +00:00
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func readAdmin(path string) (admin.Admin, error) {
|
|
|
|
|
|
|
|
if path == "-" {
|
|
|
|
|
|
|
|
adm, err := admin.FromReader(os.Stdin)
|
|
|
|
if err != nil {
|
2024-06-10 16:56:36 +00:00
|
|
|
return admin.Admin{}, fmt.Errorf("parsing admin.json from stdin: %w", err)
|
2022-10-16 15:18:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return adm, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err := os.Open(path)
|
|
|
|
if err != nil {
|
|
|
|
return admin.Admin{}, fmt.Errorf("opening file: %w", err)
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
return admin.FromReader(f)
|
|
|
|
}
|