🐛 Fix 'list-hosts' when empty #13

Merged
KaKi87 merged 5 commits from Androz2091/synced-over-ssh:fix-lists-no-host into dev 2023-03-25 19:35:41 +01:00
4 changed files with 28 additions and 21 deletions

View file

@ -9,7 +9,10 @@ export default ({
user user
}) => { }) => {
screenStream.stdin.write( screenStream.stdin.write(
new AsciiTable() (
user.getHosts().length === 0
? getString('listHosts.noHosts')
: new AsciiTable()
.setHeading('Host', 'URI') .setHeading('Host', 'URI')
.addRowMatrix(user.getHosts().map(host => [ .addRowMatrix(user.getHosts().map(host => [
host.chain host.chain
@ -27,6 +30,7 @@ export default ({
])) ]))
.toString() .toString()
.replaceAll('\n', '\r\n') .replaceAll('\n', '\r\n')
)
+ +
'\r\n' '\r\n'
); );

View file

@ -19,7 +19,7 @@ export default ({
.alias('host') .alias('host')
.description(getString('hostsCommand')) .description(getString('hostsCommand'))
.argument('[name]', getString('setHost.name')) .argument('[name]', getString('setHost.name'))
.option('-l, --list', getString('listHosts')) .option('-l, --list', getString('listHosts.title'))
.option('-a, --add', getString('addHost')) .option('-a, --add', getString('addHost'))
.option('-e, --edit [name]', getString('editHost')) .option('-e, --edit [name]', getString('editHost'))
.option('-r, --remove [name]', getString('removeHost.title')) .option('-r, --remove [name]', getString('removeHost.title'))

View file

@ -9,7 +9,7 @@ export default ({
}) => program }) => program
.command('list-hosts') .command('list-hosts')
.alias('l') .alias('l')
.description(getString('listHosts')) .description(getString('listHosts.title'))
.action(() => listHosts({ .action(() => listHosts({
screenStream, screenStream,
user user

View file

@ -16,7 +16,6 @@ i18next.init({
'invalidTotpCode': 'Wrong TOTP code', 'invalidTotpCode': 'Wrong TOTP code',
'addHost': 'Add host', 'addHost': 'Add host',
'totpCode': 'TOTP code', 'totpCode': 'TOTP code',
'listHosts': 'List hosts',
'editHost': 'Edit host', 'editHost': 'Edit host',
'COMMAND_FAILED': 'Command failed : {{- message}}', 'COMMAND_FAILED': 'Command failed : {{- message}}',
'COMMAND_ABORTED': 'Command aborted.', 'COMMAND_ABORTED': 'Command aborted.',
@ -85,6 +84,10 @@ i18next.init({
'enableTotp': 'Enable TOTP (next step)', 'enableTotp': 'Enable TOTP (next step)',
'passwordMismatch': 'This password does not match the one you entered via SSH.' 'passwordMismatch': 'This password does not match the one you entered via SSH.'
}, },
'listHosts': {
'title': 'List hosts',
'noHosts': 'No host configured yet.'
},
'setHost': { 'setHost': {
'name': 'Name', 'name': 'Name',
'nameNew': 'New name', 'nameNew': 'New name',