Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: improve usagemsgs #16

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions cmd/atomfs/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import (
)

var mountCmd = cli.Command{
Name: "mount",
Usage: "mount atomfs image",
Action: doMount,
Name: "mount",
Usage: "mount atomfs image",
ArgsUsage: "ocidir:tag target",
Action: doMount,
Flags: []cli.Flag{
cli.StringFlag{
Name: "persist, upper, upperdir",
Expand Down Expand Up @@ -50,6 +51,15 @@ func findImage(ctx *cli.Context) (string, string, error) {
}

func doMount(ctx *cli.Context) error {

if len(ctx.Args()) == 0 {
return mountUsage(ctx.App.Name)
}

ocidir, tag, err := findImage(ctx)
if err != nil {
return err
}
if !amPrivileged() {
fmt.Println("Please run as root, or in a user namespace")
fmt.Println(" You could try:")
Expand All @@ -59,11 +69,6 @@ func doMount(ctx *cli.Context) error {
fmt.Println("then run from that shell")
os.Exit(1)
}
ocidir, tag, err := findImage(ctx)
if err != nil {
return err
}

target := ctx.Args()[1]
metadir := filepath.Join(target, "meta")

Expand Down
9 changes: 5 additions & 4 deletions cmd/atomfs/umount.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
)

var umountCmd = cli.Command{
Name: "umount",
Usage: "unmount atomfs image",
Action: doUmount,
Name: "umount",
Usage: "unmount atomfs image",
ArgsUsage: "mountpoint",
Action: doUmount,
}

func umountUsage(me string) error {
return fmt.Errorf("Usage: %s mountpoint", me)
return fmt.Errorf("Usage: %s umount mountpoint", me)
}

func isMountpoint(p string) bool {
Expand Down
Loading