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

@ -4,10 +4,13 @@ local cache = require('cp.cache')
local logger = require('cp.log')
local state = require('cp.state')
function M.set(platform)
function M.login(platform)
platform = platform or state.get_platform()
if not platform then
logger.log('No platform specified. Usage: :CP credentials set <platform>', vim.log.levels.ERROR)
logger.log(
'No platform specified. Usage: :CP credentials login <platform>',
vim.log.levels.ERROR
)
return
end
@ -29,14 +32,24 @@ function M.set(platform)
end)
end
function M.clear(platform)
function M.logout(platform)
platform = platform or state.get_platform()
if not platform then
logger.log(
'No platform specified. Usage: :CP credentials logout <platform>',
vim.log.levels.ERROR
)
return
end
cache.load()
cache.clear_credentials(platform)
if platform then
logger.log(platform .. ' credentials cleared', vim.log.levels.INFO, true)
else
logger.log('all credentials cleared', vim.log.levels.INFO, true)
end
logger.log(platform .. ' credentials cleared', vim.log.levels.INFO, true)
end
function M.clear()
cache.load()
cache.clear_credentials(nil)
logger.log('all credentials cleared', vim.log.levels.INFO, true)
end
return M