Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var LogCmd = &cobra.Command{ Use: "log [target] [--raw]", Aliases: []string{"l"}, Short: "Show commit history (path)", Long: ``, Run: func(cmd *cobra.Command, args []string) { ctx := cli.Context{ WorkingDir: workingDir, Args: args, Raw: Raw, } walk := func(ss repo.RepoSnapshot, err error) { if ss.Root.String() == "b" { return } cp, _ := ss.Repo.GetCommitsPath(-1) if LogRaw { for _, cid := range cp { fmt.Printf("%v\n", cid.String()) } } else { yellow := color.New(color.FgYellow).SprintFunc() cyan := color.New(color.FgCyan).SprintFunc() fmt.Printf("[%v]\n", yellow(ss.File)) for i, cid := range cp { fmt.Printf("%v [#%v]\n", cyan(cid.String()), len(cp)-i) } } } stat, _ := os.Stdin.Stat() if (stat.Mode() & os.ModeCharDevice) == 0 { engine.WalkStream(&ctx, os.Stdin, walk) } else { engine.WalkFiles(&ctx, walk) } }, }
View Source
var (
LogRaw bool
)
View Source
var LsCmd = &cobra.Command{ Use: "inspect", Aliases: []string{"i"}, Short: "Inspect repo(s)", Long: ``, Run: func(cmd *cobra.Command, args []string) { ctx := cli.Context{ WorkingDir: workingDir, Args: args, } fmt.Println("") walk := func(ss repo.RepoSnapshot, err error) { if ss.Root.String() == "b" { return } if ss.File == "" { ss.File = "(pipe)" } yellow := color.New(color.FgYellow).SprintFunc() cyan := color.New(color.FgCyan).SprintFunc() boldCyan := color.New(color.FgCyan, color.Bold).SprintFunc() green := color.New(color.FgGreen).SprintFunc() fmt.Printf("%v:\n", yellow(ss.File)) fmt.Printf(" DID: %s Repo Version: %v\n", boldCyan(ss.Repo.SignedCommit().Did), cyan(ss.Repo.SignedCommit().Version)) fmt.Printf(" Head: %s\n", cyan(ss.Root.String())) fmt.Printf(" Sig: %s\n", cyan(hex.EncodeToString(ss.Repo.SignedCommit().Sig))) stats, _ := ss.GetCollectionStats("") keys := make([]string, 0, len(stats)) total := 0 for k := range stats { keys = append(keys, k) total += stats[k] } sort.Strings(keys) cp, _ := ss.Repo.GetCommitsPath(-1) _, v, _ := ss.Repo.GetRecord(context.TODO(), "app.bsky.actor.profile/self") dn := v["displayName"] if dn != nil { dn = boldCyan(dn) } else { dn = "(empty)" } desc := v["description"] if desc != nil { desc = cyan(strings.Replace(desc.(string), "\n", "\n ", -1)) } else { desc = "(empty)" } fmt.Printf(" Size: %s Blocks: %v Commits: %v Objects: %v\n", cyan(humanize.Bytes(uint64(ss.Size))), cyan(humanize.Comma(int64(ss.Repo.Blocks))), cyan(humanize.Comma(int64(len(cp)))), cyan(humanize.Comma(int64(total)))) fmt.Printf(" Profile:\n") fmt.Printf(" Display Name: %v\n", dn) fmt.Printf(" Description: %v\n", desc) fmt.Printf(" Collections:\n") for _, k := range keys { fmt.Printf(" %s: %v\n", green(k), cyan(humanize.Comma(int64(stats[k])))) } fmt.Printf(" Last 5 commits:\n") for i, cid := range cp { fmt.Printf(" %v\n", cyan(cid.String())) if i >= 5 { break } } if len(cp) > 5 { fmt.Printf(" %s\n", cyan("...")) } fmt.Println("") } stat, _ := os.Stdin.Stat() if (stat.Mode() & os.ModeCharDevice) == 0 { engine.WalkStream(&ctx, os.Stdin, walk) } else { engine.WalkFiles(&ctx, walk) } }, }
View Source
var ShowCmd = &cobra.Command{ Use: "show", Aliases: []string{"s"}, Short: "Show repo(s) documents", Long: ``, Run: func(cmd *cobra.Command, args []string) { ctx := cli.Context{ WorkingDir: workingDir, Args: args, Raw: Raw, } q := Query var query *gojq.Query if q != "" { tq, err := gojq.Parse(q) if err != nil { log.Fatalln("gojq parse error:", err) } else { query = tq } } qq := QueryJmes var queryJmes *jmespath.JMESPath if qq != "" { jc, err := jmespath.Compile(qq) if err != nil { return } queryJmes = jc } style := "paraiso-dark" if runtime.GOOS == "darwin" { eo, err := exec.Command("defaults", "read", "-g", "AppleInterfaceStyle").Output() if err != nil { log.Fatal(err) } if strings.Index(string(eo), "Dark") != 0 { style = "paraiso-light" } } hg := cli.Highlight(style) walk := func(ss repo.RepoSnapshot, err error) { rr := Root if GoBack > 0 { gb, _ := ss.Repo.GetCommitsPath(GoBack) rr = gb[len(gb)-1].String() } ss.LoadItems(rr) for _, e := range ss.Items { tf := Type if tf != "" { if m := regexp.MustCompile(tf).Match([]byte(e.Path)); !m { continue } } var out interface{} if q != "" || qq != "" { json, err := jsoniter.Marshal(e.Body) if err != nil { log.Fatal("jsoniter error:", err) continue } var pv interface{} err = jsoniter.Unmarshal(json, &pv) if err != nil { log.Fatal("jsoniter error:", err) continue } if q != "" { iter := query.Run(interface{}(pv)) for { v, ok := iter.Next() if !ok { break } if err, ok := v.(error); ok { log.Fatalln("gojq iter error:", err) continue } if v == nil { continue } out = v } } if qq != "" { r, err := queryJmes.Search(pv) if err != nil { log.Fatalln("jmespath error:", err) } out = r } } else { out = e.Body } stat, _ := os.Stdout.Stat() if !Raw && (stat.Mode()&os.ModeCharDevice) != 0 { cli.PrettyPrint(out, hg) } else { cli.Print(out) } } } stat, _ := os.Stdin.Stat() if (stat.Mode() & os.ModeCharDevice) == 0 { engine.WalkStream(&ctx, os.Stdin, walk) } else { engine.WalkFiles(&ctx, walk) } }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.