1
0
mirror of https://github.com/bitwarden/cli synced 2025-12-15 15:53:44 +00:00

list and get commands

This commit is contained in:
Kyle Spearrin
2018-05-14 13:37:52 -04:00
parent 2557f7239c
commit 3dd38cbe12
5 changed files with 150 additions and 11 deletions

View File

@@ -0,0 +1,42 @@
import * as program from 'commander';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { CollectionService } from 'jslib/services/collection.service';
import { FolderService } from 'jslib/services/folder.service';
export class ListCommand {
constructor(private cipherService: CipherService, private folderService: FolderService,
private collectionService: CollectionService) { }
async run(object: string, cmd: program.Command) {
switch (object) {
case 'items':
await this.listCiphers();
break;
case 'folders':
await this.listFolders();
break;
case 'collections':
await this.listCollections();
break;
default:
console.log('Unknown object: ' + object);
break;
}
}
private async listCiphers() {
const ciphers = await this.cipherService.getAllDecrypted();
console.log(JSON.stringify(ciphers));
}
private async listFolders() {
const folders = await this.folderService.getAllDecrypted();
console.log(JSON.stringify(folders));
}
private async listCollections() {
const collections = await this.collectionService.getAllDecrypted();
console.log(JSON.stringify(collections));
}
}