refactor(credentials): promote login/logout to top-level actions
Problem: :CP credentials login/logout/clear is verbose and inconsistent
with other actions that are all top-level (:CP run, :CP submit, etc.).
The clear-all subcommand is also unnecessary since re-logging in
overwrites existing credentials.
Solution: replace :CP credentials {login,logout,clear} with :CP login
[platform] and :CP logout [platform]. Remove the clear-all command and
the credentials subcommand dispatch — login/logout are now regular
actions routed through the standard action dispatcher.
This commit is contained in:
parent
98ac0aa7a7
commit
29cb81eca2
5 changed files with 28 additions and 73 deletions
|
|
@ -7,10 +7,7 @@ local state = require('cp.state')
|
|||
function M.login(platform)
|
||||
platform = platform or state.get_platform()
|
||||
if not platform then
|
||||
logger.log(
|
||||
'No platform specified. Usage: :CP credentials login <platform>',
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
logger.log('No platform specified. Usage: :CP login <platform>', vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -35,10 +32,7 @@ end
|
|||
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
|
||||
)
|
||||
logger.log('No platform specified. Usage: :CP logout <platform>', vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
cache.load()
|
||||
|
|
@ -46,10 +40,4 @@ function M.logout(platform)
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue