github.com/everdrone/grab@v0.1.7-0.20230416223925-40674b995521/internal/instance/instance.go (about)

     1  package instance
     2  
     3  import (
     4  	"github.com/everdrone/grab/internal/config"
     5  	"github.com/spf13/cobra"
     6  )
     7  
     8  type FlagsState struct {
     9  	// the path of the config file
    10  	ConfigPath string
    11  	// the verbosity level (0 = quiet, 1 = default, 2 = verbose, 3 = debug)
    12  	Verbosity int
    13  	// force overwrite of downloaded assets
    14  	Force bool
    15  	// stop at the first error
    16  	Strict bool
    17  	// skip writing to the disk
    18  	DryRun bool
    19  	// do not emit output
    20  	Quiet bool
    21  	// display the progress bar
    22  	Progress bool
    23  }
    24  
    25  type Grab struct {
    26  	// the parsed configuration
    27  	Config *config.Config
    28  	// the flags of the "get" command
    29  	Flags *FlagsState
    30  	// the caller command ("get")
    31  	Command *cobra.Command
    32  
    33  	// the original urls passed as arguments
    34  	URLs []string
    35  	// the number of assets to be downloaded
    36  	TotalAssets int64
    37  	// a map of all the regular expressions to be used
    38  	RegexCache config.RegexCacheMap
    39  }
    40  
    41  func New(cmd *cobra.Command) *Grab {
    42  	return &Grab{
    43  		Command: cmd,
    44  	}
    45  }