Skip to content
Merged
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
26 changes: 26 additions & 0 deletions acceptance/cmd/sync-without-args/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

>>> errcode [CLI] sync
Error: accepts 2 arg(s), received 0

Usage:
databricks sync [flags] SRC DST

Flags:
--dry-run simulate sync execution without making actual changes
--exclude strings patterns to exclude from sync (can be specified multiple times)
--exclude-from string file containing patterns to exclude from sync (one pattern per line)
--full perform full synchronization (default is incremental)
-h, --help help for sync
--include strings patterns to include in sync (can be specified multiple times)
--include-from string file containing patterns to include to sync (one pattern per line)
--interval duration file system polling interval (for --watch) (default 1s)
--output type type of output format (default text)
--watch watch local file system for changes

Global Flags:
--debug enable debug logging
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)


Exit code: 1
1 change: 1 addition & 0 deletions acceptance/cmd/sync-without-args/script
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
trace errcode $CLI sync
5 changes: 2 additions & 3 deletions cmd/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bytes"
"context"
"errors"
"flag"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -94,8 +93,8 @@ func (f *syncFlags) syncOptionsFromBundle(cmd *cobra.Command, args []string, b *
}

func (f *syncFlags) syncOptionsFromArgs(cmd *cobra.Command, args []string) (*sync.SyncOptions, error) {
if len(args) != 2 {
return nil, flag.ErrHelp
if err := root.ExactArgs(2)(cmd, args); err != nil {
return nil, err
}

var outputFunc func(context.Context, <-chan sync.Event, io.Writer)
Expand Down
7 changes: 3 additions & 4 deletions cmd/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sync

import (
"context"
"flag"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -47,11 +46,11 @@ func TestSyncOptionsFromArgsRequiredTwoArgs(t *testing.T) {
var err error
f := syncFlags{}
_, err = f.syncOptionsFromArgs(New(), []string{})
require.ErrorIs(t, err, flag.ErrHelp)
require.ErrorContains(t, err, "accepts 2 arg(s), received 0")
_, err = f.syncOptionsFromArgs(New(), []string{"foo"})
require.ErrorIs(t, err, flag.ErrHelp)
require.ErrorContains(t, err, "accepts 2 arg(s), received 1")
_, err = f.syncOptionsFromArgs(New(), []string{"foo", "bar", "qux"})
require.ErrorIs(t, err, flag.ErrHelp)
require.ErrorContains(t, err, "accepts 2 arg(s), received 3")
}

func TestSyncOptionsFromArgs(t *testing.T) {
Expand Down
Loading