Skip to content

Commit

Permalink
use * as default for conan list when no args (#17300)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded authored Nov 11, 2024
1 parent 90813ca commit 8bf6fb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion conan/cli/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def list(conan_api: ConanAPI, parser, *args):
args = parser.parse_args(*args)

if args.pattern is None and args.graph is None:
raise ConanException("Missing pattern or graph json file")
args.pattern = "*" # All packages
if args.graph: # a few arguments are not compatible with this
if args.pattern:
raise ConanException("Cannot define both the pattern and the graph json file")
Expand Down
16 changes: 9 additions & 7 deletions test/integration/command_v2/list_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@

class TestParamErrors:

def test_query_param_is_required(self):
def test_default_pattern(self):
c = TestClient()
c.run("list", assert_error=True)
assert "ERROR: Missing pattern or graph json file" in c.out
c.run("list")
assert "Found 0 pkg/version" in c.out

c.run("list -c", assert_error=True)
assert "ERROR: Missing pattern or graph json file" in c.out
c.run("list -c")
assert "Found 0 pkg/version" in c.out

c.run('list -r="*"', assert_error=True)
assert "ERROR: Missing pattern or graph json file" in c.out
assert "ERROR: Remotes for pattern '*' can't be found" in c.out

c.run("list --remote remote1 --cache", assert_error=True)
assert "ERROR: Missing pattern or graph json file" in c.out
assert "ERROR: Remote 'remote1' can't be found or is disabled" in c.out

def test_query_param(self):
c = TestClient()
c.run("list * --graph=myjson", assert_error=True)
assert "ERROR: Cannot define both the pattern and the graph json file" in c.out

Expand Down

0 comments on commit 8bf6fb1

Please sign in to comment.