Skip to content

Commit

Permalink
Merge from Development to Master (#35)
Browse files Browse the repository at this point in the history
* Master changes to development (#33)

* Some CI additions (#32)
  • Loading branch information
KonradIT authored Dec 16, 2022
1 parent b8814d2 commit 51a2e6d
Show file tree
Hide file tree
Showing 16 changed files with 194 additions and 198 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/buidl-win.yaml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/buidl.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/build-artifacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and release artifacts
on:
release:
types:
- created

jobs:
generate:
name: Generate cross-platform builds
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Generate build files
uses: thatisuday/go-cross-build@v1
with:
platforms: "linux/amd64, darwin/amd64, windows/amd64"
package: "mmt"
name: "mmt"
compress: "false"
dest: "dist"
- name: Upload assets for Windows
uses: actions/upload-artifact@v2
with:
name: mmt-win
path: dist-win/*
- name: Upload assets for Linux
uses: actions/upload-artifact@v2
with:
name: mmt-linux
path: dist-linux/*
- name: Upload assets for Mac OS
uses: actions/upload-artifact@v2
with:
name: mmt-darwin
path: dist-darwin/*
17 changes: 17 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build only
on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build
run: go build -v ./...
19 changes: 19 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint
on:
push:
pull_request:
permissions:
contents: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
79 changes: 42 additions & 37 deletions cmd/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,58 @@ import (

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

func get_flag_slice(cmd *cobra.Command, name string) []string {
value, err := cmd.Flags().GetStringSlice(name)
if err != nil {
cui.Error("Problem parsing "+name, err)
}
if len(value) == 0 {
value = viper.GetStringSlice(name)
}
return value
if err != nil {
cui.Error("Problem parsing "+name, err)
}
if len(value) == 0 {
value = viper.GetStringSlice(name)
}
return value
}

func get_flag_int(cmd *cobra.Command, name string, default_int string) int {
value, err := cmd.Flags().GetString(name)
if err != nil {
cui.Error("Problem parsing "+name, err)
}
if value == "" {
value = viper.GetString(name)
}
if value == "" {
value = default_int
}
int1, err := strconv.Atoi(value)
return int1
if err != nil {
cui.Error("Problem parsing "+name, err)
}
if value == "" {
value = viper.GetString(name)
}
if value == "" {
value = default_int
}
int1, err := strconv.Atoi(value)
if err != nil {
cui.Error("Problem parsing "+value, err)
}
return int1
}

func get_flag_bool(cmd *cobra.Command, name string, default_bool string) bool {
value, err := cmd.Flags().GetString(name)
if err != nil {
cui.Error("Problem parsing "+name, err)
}
if value == "" {
value = viper.GetString(name)
}
if value == "" {
value = default_bool
}
bool1, err := strconv.ParseBool(value)
return bool1
if err != nil {
cui.Error("Problem parsing "+name, err)
}
if value == "" {
value = viper.GetString(name)
}
if value == "" {
value = default_bool
}
bool1, err := strconv.ParseBool(value)
if err != nil {
cui.Error("Problem parsing "+value, err)
}
return bool1
}

44 changes: 25 additions & 19 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,25 @@ var importCmd = &cobra.Command{
Use: "import",
Short: "Import media",
Run: func(cmd *cobra.Command, args []string) {
input := get_flag_string(cmd, "input")
output := get_flag_string(cmd, "output")
camera := get_flag_string(cmd, "camera")
projectName := get_flag_string(cmd, "name")
input := get_flag_string(cmd, "input")
output := get_flag_string(cmd, "output")
camera := get_flag_string(cmd, "camera")
projectName := get_flag_string(cmd, "name")

if projectName != "" {
os.Mkdir(filepath.Join(output, projectName), 0755)
_, err := os.Stat(filepath.Join(output, projectName))
if os.IsNotExist(err) {
err := os.Mkdir(filepath.Join(output, projectName), 0755)
if err != nil {
cui.Error("Something went wrong creating project dir", err)
}
}
}

dateFormat := get_flag_string(cmd, "date")
bufferSize := get_flag_int(cmd, "buffer", "1000")
prefix := get_flag_string(cmd, "prefix")
dateRange := get_flag_slice(cmd, "range")
dateFormat := get_flag_string(cmd, "date")
bufferSize := get_flag_int(cmd, "buffer", "1000")
prefix := get_flag_string(cmd, "prefix")
dateRange := get_flag_slice(cmd, "range")

if camera != "" && output != "" {
c, err := utils.CameraGet(camera)
Expand All @@ -44,16 +50,16 @@ var importCmd = &cobra.Command{

customCameraOpts := make(map[string]interface{})
if c == utils.GoPro {
skipAuxFiles := get_flag_bool(cmd, "skip_aux", "true")
customCameraOpts["skip_aux"] = skipAuxFiles
sortBy := get_flag_slice(cmd, "sort_by")
if len(sortBy) > 0 {
customCameraOpts["sort_by"] = []string{"camera", "days"}
}

connection := get_flag_string(cmd, "connection")
skipAuxFiles := get_flag_bool(cmd, "skip_aux", "true")
customCameraOpts["skip_aux"] = skipAuxFiles
sortBy := get_flag_slice(cmd, "sort_by")
if len(sortBy) > 0 {
customCameraOpts["sort_by"] = []string{"camera", "days"}
}

connection := get_flag_string(cmd, "connection")
if connection == "" {
connection = "sd_card"
connection = "sd_card"
}
customCameraOpts["connection"] = connection
}
Expand All @@ -80,7 +86,7 @@ var importCmd = &cobra.Command{
}
return
}
color.Red("Error: required flag(s) \"camera\", \"output\" not set")
color.Red("Error: required flag(s) \"camera\", \"output\" not set")
},
}

Expand Down
8 changes: 3 additions & 5 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ var updateCmd = &cobra.Command{
Use: "update",
Short: "Update camera firmware",
Run: func(cmd *cobra.Command, args []string) {
input := get_flag_string(cmd, "input")
camera := get_flag_string(cmd, "camera")
input := get_flag_string(cmd, "input")
camera := get_flag_string(cmd, "camera")
c, err := utils.CameraGet(camera)
if err != nil {
cui.Error("Something went wrong", err)
Expand All @@ -24,14 +24,12 @@ var updateCmd = &cobra.Command{
if err != nil {
cui.Error("Something went wrong", err)
}
break
case utils.Insta360:
model := get_flag_string(cmd, "model")
model := get_flag_string(cmd, "model")
err = insta360.UpdateCamera(input, model)
if err != nil {
cui.Error("Something went wrong", err)
}
break
}

},
Expand Down
4 changes: 2 additions & 2 deletions pkg/android/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ func Import(in, out, dateFormat string, bufferSize int, prefix string, dateRange

dayFolder := filepath.Join(out, mediaDate)
if _, err := os.Stat(dayFolder); os.IsNotExist(err) {
os.Mkdir(dayFolder, 0755)
_ = os.Mkdir(dayFolder, 0755)
}

deviceInfo, err := device.DeviceInfo()
if err != nil {
return nil, err
}
if _, err := os.Stat(filepath.Join(dayFolder, deviceInfo.Product)); os.IsNotExist(err) {
os.Mkdir(filepath.Join(dayFolder, deviceInfo.Product), 0755)
_ = os.Mkdir(filepath.Join(dayFolder, deviceInfo.Product), 0755)
}
dayFolder = filepath.Join(dayFolder, deviceInfo.Product)

Expand Down
Loading

0 comments on commit 51a2e6d

Please sign in to comment.