Skip to content

Commit f705762

Browse files
committed
Nits
1 parent 1f61ef1 commit f705762

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

cmd/snapshot.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ func newSnapshotSaveCmd(cfg *env.Env) *cobra.Command {
3030
return &cobra.Command{
3131
Use: "save [destination]",
3232
Short: "Save a snapshot of the emulator state",
33-
Long: `Save a snapshot of the running emulator's state to a local file.
33+
Long: `Save a snapshot of the running emulator's state.
3434
35-
The destination must be a file path. Use a path prefix to save locally:
35+
Pass [destination] as an absolute or relative path for the exported file:
3636
37-
lstk snapshot save # saves to ./snapshot-2026-05-11T21-04-32
38-
lstk snapshot save ./my-snapshot # saves to ./my-snapshot
39-
lstk snapshot save /tmp/my-state # saves to /tmp/my-state
37+
lstk snapshot save # saves to ./snapshot-<YYYY-MM-DDTHH-mm-ss>.zip
38+
lstk snapshot save ./my-snapshot.zip # saves to ./my-snapshot.zip
39+
lstk snapshot save /tmp/my-state # saves to /tmp/my-state.zip
4040
4141
Cloud destinations are not yet supported.`,
4242
Args: cobra.MaximumNArgs(1),

internal/snapshot/destination.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package snapshot
22

33
import (
4+
"errors"
45
"fmt"
56
"os"
67
"path/filepath"
78
"strings"
89
"time"
910
)
1011

12+
var ErrCloudNotSupported = errors.New("cloud destinations are not yet supported — use a file path like ./my-snapshot.zip")
13+
1114
// ParseDestination resolves the user-supplied path to an absolute local path,
1215
// or returns an error for cloud/bare names. When dest is empty, a default name
1316
// based on now (UTC) is used, e.g. "snapshot-2026-05-11T21-04-32.zip".
@@ -16,10 +19,10 @@ func ParseDestination(dest string, now time.Time) (string, error) {
1619
if dest == "" {
1720
dest = "./" + now.UTC().Format("snapshot-2006-01-02T15-04-05")
1821
} else if strings.Contains(dest, "://") {
19-
return "", fmt.Errorf("cloud destinations are not yet supported — use a file path like ./my-snapshot.zip")
22+
return "", ErrCloudNotSupported
2023
} else if !strings.HasPrefix(dest, ".") && !strings.HasPrefix(dest, "~") && !filepath.IsAbs(dest) && filepath.Base(dest) == dest {
2124
// bare name with no path separators: reserved for future cloud pod names
22-
return "", fmt.Errorf("cloud destinations are not yet supported — use a file path like ./my-snapshot.zip")
25+
return "", ErrCloudNotSupported
2326
}
2427
if dest == "~" || strings.HasPrefix(dest, "~/") || strings.HasPrefix(dest, `~\`) {
2528
home, err := os.UserHomeDir()

internal/snapshot/destination_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,14 @@ func TestParseDestination(t *testing.T) {
7979
},
8080
{
8181
input: "my-pod",
82-
wantErr: "cloud destinations are not yet supported",
8382
wantCloudErr: true,
8483
},
8584
{
8685
input: "cloud://my-pod",
87-
wantErr: "cloud destinations are not yet supported",
8886
wantCloudErr: true,
8987
},
9088
{
9189
input: "s3://bucket/key",
92-
wantErr: "cloud destinations are not yet supported",
9390
wantCloudErr: true,
9491
},
9592
}
@@ -109,9 +106,10 @@ func TestParseDestination(t *testing.T) {
109106
if tc.wantErr != "" {
110107
require.Error(t, err)
111108
assert.Contains(t, err.Error(), tc.wantErr)
112-
if tc.wantCloudErr {
113-
assert.Contains(t, err.Error(), "./my-snapshot.zip")
114-
}
109+
return
110+
}
111+
if tc.wantCloudErr {
112+
require.ErrorIs(t, err, snapshot.ErrCloudNotSupported)
115113
return
116114
}
117115
require.NoError(t, err)

0 commit comments

Comments
 (0)