Skip to content

Commit ed6d515

Browse files
Improve tool description, user feedback and add examples (#7)
* Improve tool description, user feedback and add examples * Add link to the docs in the README and include it in the release archive
1 parent 888afe5 commit ed6d515

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ jobs:
6868

6969
- name: Prepare Build Artifacts (!windows)
7070
working-directory: ./${{ env.DIST_DIR }}
71-
run: tar -czf ${{ env.RELEASE_NAME }}.tar.gz arduino-flasher-cli -C ../ LICENSE
71+
run: tar -czf ${{ env.RELEASE_NAME }}.tar.gz arduino-flasher-cli -C ../ LICENSE README.md
7272
if: matrix.os != 'windows'
7373

7474
- name: Prepare Build Artifacts (windows)
7575
working-directory: ./${{ env.DIST_DIR }}
76-
run: 7z a -tzip ${{ env.RELEASE_NAME }}.zip arduino-flasher-cli.exe ../LICENSE
76+
run: 7z a -tzip ${{ env.RELEASE_NAME }}.zip arduino-flasher-cli.exe ../LICENSE ../README.md
7777
if: matrix.os == 'windows'
7878

7979
- name: Upload artifacts
@@ -125,7 +125,7 @@ jobs:
125125
126126
- name: Prepare Build Artifacts
127127
run: |
128-
${{ env.SEVENZ_PATH }} a -tzip ${{ env.RELEASE_NAME }}.zip arduino-flasher-cli.exe LICENSE
128+
${{ env.SEVENZ_PATH }} a -tzip ${{ env.RELEASE_NAME }}.zip arduino-flasher-cli.exe LICENSE README.md
129129
130130
- name: Upload artifacts
131131
uses: actions/upload-artifact@v4
@@ -137,7 +137,7 @@ jobs:
137137

138138
# This step is needed because the self hosted runner does not delete files automatically
139139
- name: Cleanup
140-
run: rm ${{ env.RELEASE_NAME }}.zip LICENSE arduino-flasher-cli.exe
140+
run: rm ${{ env.RELEASE_NAME }}.zip LICENSE README.md arduino-flasher-cli.exe
141141

142142
notarize-macos:
143143
name: Notarize macOS
@@ -253,7 +253,7 @@ jobs:
253253
+x \
254254
"${{ env.PROJECT_NAME }}"
255255
256-
tar -czf ${{ env.PACKAGE_FILENAME }} ${{ env.PROJECT_NAME }} LICENSE
256+
tar -czf ${{ env.PACKAGE_FILENAME }} ${{ env.PROJECT_NAME }} LICENSE README.md
257257
258258
- name: Replace artifact with notarized build
259259
uses: actions/upload-artifact@v4

main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ import (
1919
"context"
2020
"fmt"
2121
"log/slog"
22+
"os"
2223

2324
"github.com/spf13/cobra"
2425
"go.bug.st/cleanup"
25-
26+
2627
"github.com/arduino/arduino-flasher-cli/feedback"
2728
"github.com/arduino/arduino-flasher-cli/i18n"
2829
)
@@ -34,7 +35,9 @@ var format string
3435
func main() {
3536
rootCmd := &cobra.Command{
3637
Use: "arduino-flasher-cli",
37-
Short: "A CLI to update and flash the Debian image",
38+
Short: "A CLI to update your Arduino UNO Q board, by downloading and flashing the latest Arduino Linux image",
39+
Example: " " + os.Args[0] + " flash latest\n" +
40+
" " + os.Args[0] + " list\n",
3841
PersistentPreRun: func(cmd *cobra.Command, args []string) {
3942
format, ok := feedback.ParseOutputFormat(format)
4043
if !ok {

updater/download_image.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,27 @@ type Release struct {
4646
// DownloadConfirmCB is a function that is called when a Debian image is ready to be downloaded.
4747
type DownloadConfirmCB func(target string) (bool, error)
4848

49-
func DownloadAndExtract(client *Client, targetVersion string, upgradeConfirmCb DownloadConfirmCB, forceYes bool) (*paths.Path, error) {
49+
func DownloadAndExtract(client *Client, targetVersion string, upgradeConfirmCb DownloadConfirmCB, forceYes bool) (*paths.Path, string, error) {
5050
tmpZip, version, err := DownloadImage(client, targetVersion, upgradeConfirmCb, forceYes)
5151
if err != nil {
52-
return nil, fmt.Errorf("error downloading the image: %v", err)
52+
return nil, "", fmt.Errorf("error downloading the image: %v", err)
5353
}
5454

5555
// Download not confirmed
5656
if tmpZip == nil {
57-
return nil, nil
57+
return nil, "", nil
5858
}
5959

6060
err = ExtractImage(tmpZip, tmpZip.Parent())
6161
if err != nil {
62-
return nil, fmt.Errorf("error extracting the image: %v", err)
62+
return nil, "", fmt.Errorf("error extracting the image: %v", err)
6363
}
6464

6565
imagePath := tmpZip.Parent().Join("arduino-unoq-debian-image-" + version)
66-
return imagePath, nil
66+
if targetVersion == "latest" {
67+
version += "(latest)"
68+
}
69+
return imagePath, version, nil
6770
}
6871

6972
func DownloadImage(client *Client, targetVersion string, upgradeConfirmCb DownloadConfirmCB, forceYes bool) (*paths.Path, string, error) {

updater/flasher.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func Flash(ctx context.Context, imagePath *paths.Path, version string, forceYes
3232
if !imagePath.Exist() {
3333
client := NewClient()
3434

35-
tempImagePath, err := DownloadAndExtract(client, version, func(target string) (bool, error) {
35+
tempImagePath, v, err := DownloadAndExtract(client, version, func(target string) (bool, error) {
3636
feedback.Printf("Found Debian image version: %s", target)
3737
feedback.Printf("Do you want to download it? (yes/no)")
3838

@@ -56,6 +56,7 @@ func Flash(ctx context.Context, imagePath *paths.Path, version string, forceYes
5656

5757
defer tempImagePath.Parent().RemoveAll()
5858

59+
version = v
5960
imagePath = tempImagePath
6061
} else if !imagePath.IsDir() {
6162
temp, err := GetTempDir("extract-")
@@ -77,7 +78,7 @@ func Flash(ctx context.Context, imagePath *paths.Path, version string, forceYes
7778
imagePath = tempContent[0]
7879
}
7980

80-
return FlashBoard(ctx, imagePath.String(), func(target string) (bool, error) {
81+
return FlashBoard(ctx, imagePath.String(), version, func(target string) (bool, error) {
8182
feedback.Print("\nWARNING: flashing a new Linux image on the board will erase any existing data you have on it.")
8283
feedback.Printf("Do you want to procede and flash %s on the board? (yes/no)", target)
8384

@@ -91,9 +92,9 @@ func Flash(ctx context.Context, imagePath *paths.Path, version string, forceYes
9192
}, forceYes)
9293
}
9394

94-
func FlashBoard(ctx context.Context, downloadedImagePath string, upgradeConfirmCb DownloadConfirmCB, forceYes bool) error {
95+
func FlashBoard(ctx context.Context, downloadedImagePath string, version string, upgradeConfirmCb DownloadConfirmCB, forceYes bool) error {
9596
if !forceYes {
96-
res, err := upgradeConfirmCb(downloadedImagePath)
97+
res, err := upgradeConfirmCb(version)
9798
if err != nil {
9899
return err
99100
}
@@ -152,5 +153,7 @@ func FlashBoard(ctx context.Context, downloadedImagePath string, upgradeConfirmC
152153
return err
153154
}
154155

156+
feedback.Print("\nThe board has been successfully flashed. You can now power-cycle the board (unplug and re-plug). Remember to remove the jumper.")
157+
155158
return nil
156159
}

0 commit comments

Comments
 (0)