func main() { flag.Usage = func() { fmt.Fprintln(os.Stderr, "Shows a serialization of a Noms object\n") fmt.Fprintln(os.Stderr, "Usage: noms show <object>\n") flag.PrintDefaults() fmt.Fprintf(os.Stderr, "\nSee \"Spelling Objects\" at https://github.com/attic-labs/noms/blob/master/doc/spelling.md for details on the object argument.\n\n") } flag.Parse() if *showHelp { flag.Usage() return } if len(flag.Args()) != 1 { util.CheckError(errors.New("expected exactly one argument")) } database, value, err := spec.GetPath(flag.Arg(0)) util.CheckError(err) waitChan := outputpager.PageOutput(!*outputpager.NoPager) types.WriteEncodedValueWithTags(os.Stdout, value) fmt.Fprintf(os.Stdout, "\n") database.Close() if waitChan != nil { os.Stdout.Close() <-waitChan } }
func main() { color = flag.Int("color", -1, "value of 1 forces color on, 2 forces color off") maxLines = flag.Int("max-lines", 10, "max number of lines to show per commit (-1 for all lines)") maxCommits = flag.Int("n", 0, "max number of commits to display (0 for all commits)") showHelp = flag.Bool("help", false, "show help text") showGraph = flag.Bool("graph", false, "show ascii-based commit hierarcy on left side of output") showValue = flag.Bool("show-value", false, "show commit value rather than diff information -- this is temporary") flag.Usage = func() { fmt.Fprintln(os.Stderr, "Displays the history of a Noms dataset\n") fmt.Fprintln(os.Stderr, "Usage: noms log <commitObject>") fmt.Fprintln(os.Stderr, "commitObject must be a dataset or object spec that refers to a commit.") flag.PrintDefaults() fmt.Fprintf(os.Stderr, "\nSee \"Spelling Objects\" at https://github.com/attic-labs/noms/blob/master/doc/spelling.md for details on the object argument.\n\n") } flag.Parse() if *showHelp { flag.Usage() return } if len(flag.Args()) != 1 { util.CheckError(errors.New("expected exactly one argument")) } useColor = shouldUseColor() database, value, err := spec.GetPath(flag.Arg(0)) if err != nil { util.CheckErrorNoUsage(err) } defer database.Close() waitChan := outputpager.PageOutput(!*outputpager.NoPager) origCommit, ok := value.(types.Struct) if !ok || !origCommit.Type().Equals(datas.CommitType()) { util.CheckError(fmt.Errorf("%s does not reference a Commit object", flag.Arg(0))) } iter := NewCommitIterator(database, origCommit) displayed := 0 if *maxCommits <= 0 { *maxCommits = math.MaxInt32 } for ln, ok := iter.Next(); ok && displayed < *maxCommits; ln, ok = iter.Next() { if printCommit(ln, database) != nil { break } displayed++ } if waitChan != nil { os.Stdout.Close() <-waitChan } }
func main() { flag.Usage = func() { fmt.Fprintln(os.Stderr, "Shows the difference between two objects\n") fmt.Fprintln(os.Stderr, "Usage: noms diff <object1> <object2>\n") flag.PrintDefaults() fmt.Fprintf(os.Stderr, "\nSee \"Spelling Objects\" at https://github.com/attic-labs/noms/blob/master/doc/spelling.md for details on the object argument.\n\n") } flag.Parse() if *showHelp { flag.Usage() return } if len(flag.Args()) != 2 { util.CheckError(errors.New("expected exactly two arguments")) } db1, value1, err := spec.GetPath(flag.Arg(0)) util.CheckError(err) defer db1.Close() db2, value2, err := spec.GetPath(flag.Arg(1)) util.CheckError(err) defer db2.Close() waitChan := outputpager.PageOutput(!*outputpager.NoPager) diff.Diff(os.Stdout, value1, value2) fmt.Fprintf(os.Stdout, "\n") if waitChan != nil { os.Stdout.Close() <-waitChan } }