MCPcopy Create free account
hub / github.com/Debian/dcs / create

Function create

cmd/dcs/create.go:22–59  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

20`
21
22func create(args []string) error {
23 fset := flag.NewFlagSet("create", flag.ExitOnError)
24 fset.Usage = usage(fset, createHelp)
25 var idx string
26 fset.StringVar(&idx, "idx", "", "path to the index file to work with")
27 if err := fset.Parse(args); err != nil {
28 return err
29 }
30 if idx == "" || fset.NArg() != 1 {
31 fset.Usage()
32 os.Exit(1)
33 }
34
35 filter.Init()
36
37 w, err := index.Create(idx)
38 if err != nil {
39 return err
40 }
41
42 if err := w.AddDir(
43 fset.Arg(0),
44 filepath.Clean(fset.Arg(0))+"/",
45 filter.Ignored,
46 func(path string, _ os.FileInfo, err error) error {
47 log.Printf("skipping %q: %v", path, err)
48 return nil
49 },
50 nil,
51 ); err != nil {
52 return err
53 }
54
55 if err := w.Flush(); err != nil {
56 return err
57 }
58 return nil
59}

Callers 1

mainFunction · 0.85

Calls 5

InitFunction · 0.92
CreateFunction · 0.92
usageFunction · 0.85
AddDirMethod · 0.80
FlushMethod · 0.45

Tested by

no test coverage detected