github.com/grailbio/bigslice@v0.0.0-20230519005545-30c4c12152ad/cmd/bigslice/build.go (about)

     1  // Copyright 2019 GRAIL, Inc. All rights reserved.
     2  // Use of this source code is governed by the Apache 2.0
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"context"
     9  	"flag"
    10  	"fmt"
    11  	"log"
    12  	"os"
    13  
    14  	"github.com/grailbio/base/must"
    15  	"github.com/grailbio/bigslice/cmd/bigslice/bigslicecmd"
    16  )
    17  
    18  func buildCmdUsage(flags *flag.FlagSet) {
    19  	fmt.Fprint(os.Stderr, bigslicecmd.BuildUsage)
    20  	flags.PrintDefaults()
    21  	os.Exit(2)
    22  }
    23  
    24  func buildCmd(args []string) {
    25  	var (
    26  		flags  = flag.NewFlagSet("bigslice build", flag.ExitOnError)
    27  		output = flags.String("o", "", "output path")
    28  	)
    29  	flags.Usage = func() { buildCmdUsage(flags) }
    30  	must.Nil(flags.Parse(args))
    31  
    32  	if len(flags.Args()) == 0 {
    33  		log.Fatal("no arguments")
    34  	}
    35  
    36  	paths := flags.Args()
    37  	if len(paths) == 0 {
    38  		paths = []string{"."}
    39  	}
    40  	ctx := context.Background()
    41  	bigslicecmd.Build(ctx, paths, *output)
    42  }