本文整理匯總了Golang中github.com/disorganizer/brig/daemon.Client.List方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.List方法的具體用法?Golang Client.List怎麽用?Golang Client.List使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/disorganizer/brig/daemon.Client
的用法示例。
在下文中一共展示了Client.List方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleList
func handleList(ctx *cli.Context, client *daemon.Client) error {
path := "/"
if ctx.NArg() > 0 {
path = prefixSlash(ctx.Args().First())
}
depth := ctx.Int("depth")
if ctx.Bool("recursive") {
depth = -1
}
entries, err := client.List(path, depth)
if err != nil {
return ExitCode{
UnknownError,
fmt.Sprintf("ls: %v", err),
}
}
for _, entry := range entries {
modTime := time.Time{}
if err := modTime.UnmarshalText(entry.ModTime); err != nil {
log.Warningf("Could not parse mtime (%s): %v", entry.ModTime, err)
continue
}
fmt.Printf(
"%s\t%s\t%s\n",
colors.Colorize(
humanize.Bytes(uint64(entry.NodeSize)),
colors.Green,
),
colors.Colorize(
humanize.Time(modTime),
colors.Cyan,
),
colors.Colorize(
entry.Path,
colors.Magenta,
),
)
}
return nil
}
示例2: handleTree
func handleTree(ctx *cli.Context, client *daemon.Client) error {
path := "/"
if ctx.NArg() > 0 {
path = prefixSlash(ctx.Args().First())
}
depth := ctx.Int("depth")
dirlist, err := client.List(path, depth)
if err != nil {
return ExitCode{
UnknownError,
fmt.Sprintf("ls: %v", err),
}
}
if err := showTree(dirlist, depth); err != nil {
return ExitCode{
UnknownError,
fmt.Sprintf("Printing tree failed: %v", err),
}
}
return nil
}