aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/app
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/app')
-rw-r--r--cmd/app/app.go17
-rw-r--r--cmd/app/main.go25
2 files changed, 19 insertions, 23 deletions
diff --git a/cmd/app/app.go b/cmd/app/app.go
index 4e4f314d..9679413f 100644
--- a/cmd/app/app.go
+++ b/cmd/app/app.go
@@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"io"
+ "os"
"strconv"
"strings"
@@ -335,3 +336,19 @@ func parse(
return &c, nil
}
+
+// list prints names of non-hidden entries in pathname.
+func list(pathname *check.Absolute, dir bool) error {
+ dents, err := os.ReadDir(pathname.String())
+ if err != nil {
+ return err
+ }
+ for _, dent := range dents {
+ name := dent.Name()
+ if (dent.IsDir() != dir) || (len(name) > 0 && name[0] == '.') {
+ continue
+ }
+ fmt.Println(dent.Name())
+ }
+ return nil
+}
diff --git a/cmd/app/main.go b/cmd/app/main.go
index 146a5546..00bceb57 100644
--- a/cmd/app/main.go
+++ b/cmd/app/main.go
@@ -7,7 +7,6 @@ package main
import (
"context"
"errors"
- "fmt"
"io"
"log"
"os"
@@ -77,17 +76,7 @@ func main() {
"enter", "Enter mutable state template",
func(args []string) error {
if len(args) != 1 {
- dents, err := os.ReadDir(template.String())
- if err != nil {
- return err
- }
- for _, dent := range dents {
- if !dent.IsDir() {
- continue
- }
- fmt.Println(dent.Name())
- }
- return nil
+ return list(template, true)
}
config := hst.Config{
@@ -159,17 +148,7 @@ func main() {
"run", "Start the named application",
func(args []string) error {
if len(args) < 1 {
- dents, err := os.ReadDir(base.Append("app").String())
- if err != nil {
- return err
- }
- for _, dent := range dents {
- if dent.IsDir() {
- continue
- }
- fmt.Println(dent.Name())
- }
- return nil
+ return list(base.Append("app"), false)
}
var config *hst.Config