Added 'list' command to CredentialMenu.php
https://git.n64.cc/nosial/ncc/-/issues/27
This commit is contained in:
parent
5a83a7f6fe
commit
e38a4df2ee
1 changed files with 38 additions and 0 deletions
|
@ -50,9 +50,47 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($args['list']))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
self::listEntries();
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
Console::outException('Cannot list credentials.', $e, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self::displayOptions();
|
self::displayOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the list of entries in the vault
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function listEntries(): void
|
||||||
|
{
|
||||||
|
$credential_manager = new CredentialManager();
|
||||||
|
$entries = $credential_manager->getVault()->getEntries();
|
||||||
|
|
||||||
|
if(count($entries) === 0)
|
||||||
|
{
|
||||||
|
Console::out('No credentials found.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($entries as $entry)
|
||||||
|
{
|
||||||
|
Console::out(sprintf('%s%s', $entry->getName(), ($entry->isEncrypted() ? ' (encrypted)' : '')));
|
||||||
|
}
|
||||||
|
|
||||||
|
Console::out('Total: ' . count($entries));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $args
|
* @param $args
|
||||||
* @return void
|
* @return void
|
||||||
|
|
Loading…
Add table
Reference in a new issue