Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make GetFlagString() process the default string #127

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/apply_lut.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@
var applyLutCmd = &cobra.Command{
Use: "apply-lut",
Short: "Apply LUT to one or more images",
Run: func(cmd *cobra.Command, args []string) {

Check warning on line 90 in cmd/apply_lut.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
input := getFlagString(cmd, "input")
lutFile := getFlagString(cmd, "lut")
input := getFlagString(cmd, "input", "")
lutFile := getFlagString(cmd, "lut", "")

intensity := getFlagInt(cmd, "intensity", "100")
intensityParsed := float64(intensity) / 100

quality := getFlagInt(cmd, "quality", "100")
resizeTo := getFlagString(cmd, "resize")
resizeTo := getFlagString(cmd, "resize", "")

stat, err := os.Stat(input)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/export_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ var exportTags = &cobra.Command{
Use: "export-tags",
Short: "Export HiLight/other tags in video",
Run: func(cmd *cobra.Command, args []string) {
input := getFlagString(cmd, "input")
format := getFlagString(cmd, "format")
output := getFlagString(cmd, "output")
input := getFlagString(cmd, "input", "")
format := getFlagString(cmd, "format", "")
output := getFlagString(cmd, "output", "")

stat, err := os.Stat(input)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion cmd/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
"github.com/spf13/viper"
)

func getFlagString(cmd *cobra.Command, name string) string {
func getFlagString(cmd *cobra.Command, name string, defaultString string) string {
value, err := cmd.Flags().GetString(name)
if err != nil {
cui.Error("Problem parsing "+name, err)

Check failure on line 14 in cmd/helper.go

View workflow job for this annotation

GitHub Actions / lint

string `Problem parsing ` has 6 occurrences, make it a constant (goconst)
}
if value == "" {
value = viper.GetString(name)
}
if value == "" {
value = defaultString
}
return value
}

Expand Down
18 changes: 9 additions & 9 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
var importCmd = &cobra.Command{
Use: "import",
Short: "Import media",
Run: func(cmd *cobra.Command, args []string) {

Check warning on line 27 in cmd/import.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
input := getFlagString(cmd, "input")
output := getFlagString(cmd, "output")
camera := getFlagString(cmd, "camera")
projectName := getFlagString(cmd, "name")
input := getFlagString(cmd, "input", "")
output := getFlagString(cmd, "output", "")
camera := getFlagString(cmd, "camera", "")
projectName := getFlagString(cmd, "name", "")

if projectName != "" {
_, err := os.Stat(filepath.Join(output, projectName))
Expand All @@ -40,12 +40,12 @@
}
}

dateFormat := getFlagString(cmd, "date")
dateFormat := getFlagString(cmd, "date", "dd-mm-yyyy")
bufferSize := getFlagInt(cmd, "buffer", "1000")
prefix := getFlagString(cmd, "prefix")
prefix := getFlagString(cmd, "prefix", "")
dateRange := getFlagSlice(cmd, "range")
cameraName := getFlagString(cmd, "camera-name")
connection := utils.ConnectionType(getFlagString(cmd, "connection"))
cameraName := getFlagString(cmd, "camera-name", "")
connection := utils.ConnectionType(getFlagString(cmd, "connection", ""))
skipAuxFiles := getFlagBool(cmd, "skip-aux", "true")
sortBy := getFlagSlice(cmd, "sort-by")
if len(sortBy) == 0 {
Expand Down Expand Up @@ -137,7 +137,7 @@
importCmd.Flags().StringP("output", "o", "", "Output directory for sorted media")
importCmd.Flags().StringP("name", "n", "", "Project name")
importCmd.Flags().StringP("camera", "c", "", "Camera type")
importCmd.Flags().StringP("date", "d", "dd-mm-yyyy", "Date format, dd-mm-yyyy by default")
importCmd.Flags().StringP("date", "d", "", "Date format, dd-mm-yyyy by default")
importCmd.Flags().StringP("buffer", "b", "", "Buffer size for copying, default is 1000 bytes")
importCmd.Flags().StringP("prefix", "p", "", "Prefix for each file, pass `cameraname` to prepend the camera name (eg: Hero9 Black)")
importCmd.Flags().StringSlice("range", []string{}, "A date range, eg: 01-05-2020,05-05-2020 -- also accepted: `today`, `yesterday`, `week`")
Expand Down
6 changes: 3 additions & 3 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
var updateCmd = &cobra.Command{
Use: "update",
Short: "Update camera firmware",
Run: func(cmd *cobra.Command, args []string) {

Check warning on line 14 in cmd/update.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
input := getFlagString(cmd, "input")
camera := getFlagString(cmd, "camera")
input := getFlagString(cmd, "input", "")
camera := getFlagString(cmd, "camera", "")
c, err := utils.CameraGet(camera)
if err != nil {
cui.Error("Something went wrong", err)
Expand All @@ -25,7 +25,7 @@
cui.Error("Something went wrong", err)
}
case utils.Insta360:
model := getFlagString(cmd, "model")
model := getFlagString(cmd, "model", "")
err = insta360.UpdateCamera(input, model)
if err != nil {
cui.Error("Something went wrong", err)
Expand Down
Loading