Skip to content

pylings with no workspace should auto-init instead of erroring #13

Description

@abhiksark

Part of the 0.3.0 adoption roadmap — First-run UX.

Why (adoption impact)

The #1 beginner trap. A new user installs pylings, runs pylings, and — if they're not inside an initialized workspace — gets a ManifestError (exit 2). They have no idea they were supposed to run pylings init --path ... first. We lose them at the very first command.

Current state

  • pylings/cli.py main(): with no subcommand, args.command in (None, "watch", "start", "topics") calls run_tui(args.root, ...). args.root defaults to the current directory.
  • If args.root has no info.toml, manifest loading raises ManifestError → caught at the bottom of main() → prints pylings: <error> and returns 2.
  • Workspace creation lives in _cmd_init (pylings/core/...), invoked today only via the explicit init subcommand.

Scope / acceptance criteria

  • When pylings runs with no workspace in args.root, do NOT hard-error. Instead either:
    • (preferred) detect "no info.toml here", print a one-line explanation, auto-init a workspace in a sensible default location (e.g. ./pylings-workspace or args.root), and launch into the first exercise; or
    • prompt the user No workspace found here. Create one in ./pylings-workspace? [Y/n] and proceed on yes.
  • If a workspace already exists, behavior is unchanged.
  • --root is still respected.
  • Non-interactive/CI contexts (no TTY) fall back to a clear message + exit code, not a hang.
  • Decide and document the default workspace path; keep it predictable.

Where to look

  • pylings/cli.py (main, _cmd_init, _build_parser, the args.command in (None, ...) branch).
  • pylings/core/manifest.py (ManifestError, load).

Out of scope

Verify

  • In a fresh empty dir, pylings should get a beginner into exercise 1 (or a clear y/N prompt), not a traceback or bare ManifestError.
  • Add/extend a CLI integration test under tests/integration/ for the "no workspace" path (assert it inits or prompts, doesn't exit 2 silently).

Difficulty

enhancement · good first issue — contained CLI change, ~half a day with tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions