refactor(credentials): rename set/clear to login/logout/clear (#291)

## Problem

The `set` and `clear` subcommands don't clearly convey their intent —
`set`
reads like a generic setter rather than an auth action, and `clear`
overloads
single-platform and all-platform semantics in one subcommand.

## Solution

Rename `set` to `login`, split `clear` into `logout` (per-platform,
defaults
to active) and `clear` (all platforms).

New API:
- `:CP credentials login [platform]` — prompt and save credentials
- `:CP credentials logout [platform]` — remove credentials for one
platform
- `:CP credentials clear` — remove all stored credentials
This commit is contained in:
Barrett Ruth 2026-03-04 12:53:37 -05:00 committed by GitHub
parent 18a60da2d8
commit 98ac0aa7a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 58 additions and 29 deletions

View file

@ -86,14 +86,22 @@ local function parse_command(args)
elseif first == 'credentials' then
local subcommand = args[2]
if not subcommand then
return { type = 'error', message = 'credentials command requires subcommand (set, clear)' }
return {
type = 'error',
message = 'credentials command requires subcommand (login, logout, clear)',
}
end
if vim.tbl_contains({ 'set', 'clear' }, subcommand) then
if vim.tbl_contains({ 'login', 'logout' }, subcommand) then
return {
type = 'credentials',
subcommand = subcommand,
platform = args[3],
}
elseif subcommand == 'clear' then
return {
type = 'credentials',
subcommand = 'clear',
}
else
return { type = 'error', message = 'unknown credentials subcommand: ' .. subcommand }
end
@ -368,10 +376,12 @@ function M.handle_command(opts)
setup.setup_contest(platform, contest_id, problem_id, cmd.language)
elseif cmd.type == 'credentials' then
local creds = require('cp.credentials')
if cmd.subcommand == 'set' then
creds.set(cmd.platform)
if cmd.subcommand == 'login' then
creds.login(cmd.platform)
elseif cmd.subcommand == 'logout' then
creds.logout(cmd.platform)
elseif cmd.subcommand == 'clear' then
creds.clear(cmd.platform)
creds.clear()
end
elseif cmd.type == 'cache' then
local cache_commands = require('cp.commands.cache')