feat(cli): add --profile flag to aw-cli (step 6 of #1399) - #151
Conversation
…ename filter --profile NAME selects a named instance profile, resolving to the activitywatch-<profile> platform dirs introduced in ActivityWatch#149. --testing remains as an alias for --profile testing. The qt subcommand now forwards --profile <name> to aw-qt (which gained profile support in aw-qt#128). The logs subcommand relies on AW_PROFILE being set in the environment (done by the group callback) so get_log_dir() already returns the profile-specific directory; no filename-based filtering is needed. find_oldest_log() drops the `testing` parameter accordingly. Step 6 of ActivityWatch/activitywatch#1399.
Greptile SummaryThe PR adds named-profile selection to aw-cli, keeps --testing as an alias, forwards profiles to aw-qt, and simplifies profile-isolated log selection.
Confidence Score: 4/5The inherited-profile regression should be fixed before merging because ordinary aw-cli commands can silently operate on the default instance instead of the profile selected by their environment. The new callback removes AW_PROFILE when no explicit option is present, changing directory lookup, log inspection, and the environment inherited by aw-qt from the selected profile to the default profile. Files Needing Attention: aw_cli/main.py Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[aw-cli options or inherited AW_PROFILE] --> B[Group callback]
B --> C[AW_PROFILE environment]
C --> D[directories]
C --> E[logs]
B --> F[qt]
F --> G[aw-qt --profile NAME]
Reviews (1): Last reviewed commit: "feat(cli): add --profile flag to aw-cli,..." | Re-trigger Greptile |
Without this fix, running 'aw-cli <cmd>' with AW_PROFILE already set in the environment would silently clear it, making directory/log lookups fall back to the default profile instead of the inherited one. Addresses Greptile's inherited-profile regression note on ActivityWatch#151.
|
CI is green (macOS, Ubuntu, Windows, lint). Greptile's P1 suggestion (guard |
Summary
Step 6 of ActivityWatch/activitywatch#1399 — adds
--profile NAMEtoaw-cliand drops the now-obsolete testing-based log filename filter.What changed
aw_cli/__main__.pymaingroup gains--profile NAMEoption.--testingstays as a backward-compat alias for--profile testing.os.environ["AW_PROFILE"]before any subcommand runs, soget_log_dir()/get_data_dir()/ etc. automatically resolve to the correct profile directory (the isolation introduced in feat(dirs): profile isolation via AW_PROFILE appname suffix #149).qtsubcommand forwards--profile NAMEtoaw-qt(which gained profile support in aw-qt#128).logssubcommand no longer passestestingdown tofind_oldest_log— the dir itself is already profile-specific.directoriessubcommand needs no changes; it callsget_*_dir(None)which readsAW_PROFILEfrom the environment.aw_cli/log.pyfind_oldest_logdrops thetesting: boolparameter. With per-profile appname dirs (feat(dirs): profile isolation via AW_PROFILE appname suffix #149), every.logfile in the module directory belongs to the active profile — no filename filtering needed.Tests
6 new tests in
tests/test_cli_log.pycovering the updatedfind_oldest_logbehaviour. Full suite: 196 passed, 2 skipped.Rollout context
This is step 6 in the rollout sequence. Steps 1–5 are merged:
The aw-cli
qtsubcommand spawnsaw-qt, so step 6 was blocked on step 5 being merged first. That gate cleared today.