Skip to content

Commit

Permalink
make project name arg param again
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed May 14, 2024
1 parent c6ba3a3 commit d9da401
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions logfire/_internal/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def parse_use_project(args: argparse.Namespace) -> None:
"""Use an existing project."""
data_dir = Path(args.data_dir)
logfire_url = args.logfire_url
project_name = args.project
project_name = args.project_name
organization = args.org
console = Console(file=sys.stderr)

Expand Down Expand Up @@ -438,7 +438,7 @@ def _main(args: list[str] | None = None) -> None:
cmd_projects_new.set_defaults(func=parse_create_new_project)

cmd_projects_use = projects_subparsers.add_parser('use', help='use a project')
cmd_projects_use.add_argument('--project', help='project name')
cmd_projects_use.add_argument('project_name', nargs='?', help='project name')
cmd_projects_use.add_argument('--org', help='project organization')
cmd_projects_use.add_argument('--data-dir', default='.logfire')
cmd_projects_use.set_defaults(func=parse_use_project)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ def test_projects_use(tmp_dir_cwd: Path, default_credentials: Path) -> None:
[create_project_response],
)

main(['projects', 'use', '--project', 'myproject'])
main(['projects', 'use', 'myproject'])

console_calls = [re.sub(r'^call(\(\).)?', '', str(call)) for call in console.mock_calls]
assert console_calls == [
Expand Down Expand Up @@ -904,7 +904,7 @@ def test_projects_use_multiple(tmp_dir_cwd: Path, default_credentials: Path) ->
[create_project_response],
)

main(['projects', 'use', '--project', 'myproject'])
main(['projects', 'use', 'myproject'])

console_calls = [re.sub(r'^call(\(\).)?', '', str(call)) for call in console.mock_calls]
assert console_calls == [
Expand Down Expand Up @@ -962,7 +962,7 @@ def test_projects_use_multiple_with_org(tmp_dir_cwd: Path, default_credentials:
[create_project_response],
)

main(['projects', 'use', '--project', 'myproject', '--org', 'fake_org'])
main(['projects', 'use', 'myproject', '--org', 'fake_org'])

console_calls = [re.sub(r'^call(\(\).)?', '', str(call)) for call in console.mock_calls]
assert console_calls == [
Expand Down Expand Up @@ -1000,7 +1000,7 @@ def test_projects_use_wrong_project(tmp_dir_cwd: Path, default_credentials: Path
[create_project_response],
)

main(['projects', 'use', '--project', 'wrong-project', '--org', 'fake_org'])
main(['projects', 'use', 'wrong-project', '--org', 'fake_org'])

assert prompt_mock.mock_calls == [
call(
Expand Down Expand Up @@ -1040,7 +1040,7 @@ def test_projects_use_wrong_project_give_up(tmp_dir_cwd: Path, default_credentia
json=[{'organization_name': 'fake_org', 'project_name': 'myproject'}],
)

main(['projects', 'use', '--project', 'wrong-project', '--org', 'fake_org'])
main(['projects', 'use', 'wrong-project', '--org', 'fake_org'])

assert prompt_mock.mock_calls == [
call(
Expand Down Expand Up @@ -1071,7 +1071,7 @@ def test_projects_use_without_projects(tmp_dir_cwd: Path, capsys: pytest.Capture
json=[],
)

main(['projects', 'use', '--project', 'myproject'])
main(['projects', 'use', 'myproject'])

assert (
re.sub(r'\s+', ' ', capsys.readouterr().err).strip()
Expand Down Expand Up @@ -1104,7 +1104,7 @@ def test_projects_use_error(tmp_dir_cwd: Path, default_credentials: Path) -> Non
)

with pytest.raises(LogfireConfigError, match='Invalid credentials, when initializing project:'):
main(['projects', 'use', '--project', 'myproject', '--org', 'fake_org'])
main(['projects', 'use', 'myproject', '--org', 'fake_org'])


def test_projects_use_write_token_error(tmp_dir_cwd: Path, default_credentials: Path) -> None:
Expand All @@ -1126,7 +1126,7 @@ def test_projects_use_write_token_error(tmp_dir_cwd: Path, default_credentials:
)

with pytest.raises(LogfireConfigError, match='Error creating project write token.'):
main(['projects', 'use', '--project', 'myproject', '--org', 'fake_org'])
main(['projects', 'use', 'myproject', '--org', 'fake_org'])


def test_info(capsys: pytest.CaptureFixture[str]) -> None:
Expand Down

0 comments on commit d9da401

Please sign in to comment.