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

add list items --url <url> command. resolves #32

This commit is contained in:
Kyle Spearrin
2018-10-13 22:27:33 -04:00
parent 4639aa613e
commit 73c597f649
7 changed files with 35 additions and 24 deletions

View File

@@ -88,10 +88,10 @@ export class Main {
async (expired: boolean) => await this.logout());
this.environmentService = new EnvironmentService(this.apiService, this.storageService, null);
this.userService = new UserService(this.tokenService, this.storageService);
this.containerService = new ContainerService(this.cryptoService, this.platformUtilsService);
this.containerService = new ContainerService(this.cryptoService);
this.settingsService = new SettingsService(this.userService, this.storageService);
this.cipherService = new CipherService(this.cryptoService, this.userService, this.settingsService,
this.apiService, this.storageService, this.i18nService, this.platformUtilsService, null);
this.apiService, this.storageService, this.i18nService, null);
this.folderService = new FolderService(this.cryptoService, this.userService, this.apiService,
this.storageService, this.i18nService, this.cipherService);
this.collectionService = new CollectionService(this.cryptoService, this.userService, this.storageService,

View File

@@ -1,5 +1,7 @@
import * as program from 'commander';
import { CipherView } from 'jslib/models/view/cipherView';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { CollectionService } from 'jslib/abstractions/collection.service';
import { FolderService } from 'jslib/abstractions/folder.service';
@@ -36,7 +38,12 @@ export class ListCommand {
}
private async listCiphers(cmd: program.Command) {
let ciphers = await this.cipherService.getAllDecrypted();
let ciphers: CipherView[];
if (cmd.url != null && cmd.url.trim() !== '') {
ciphers = await this.cipherService.getAllDecryptedForUrl(cmd.url);
} else {
ciphers = await this.cipherService.getAllDecrypted();
}
if (cmd.folderid != null || cmd.collectionid != null || cmd.organizationid != null) {
ciphers = ciphers.filter((c) => {

View File

@@ -194,6 +194,7 @@ export class Program {
.command('list <object>')
.description('List an array of objects from the vault.')
.option('--search <search>', 'Perform a search on the listed objects.')
.option('--url <url>', 'Filter items of type login with a url-match search.')
.option('--folderid <folderid>', 'Filter items by folder id.')
.option('--collectionid <collectionid>', 'Filter items by collection id.')
.option('--organizationid <organizationid>', 'Filter items or collections by organization id.')
@@ -216,6 +217,7 @@ export class Program {
writeLn(' bw list items');
writeLn(' bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2');
writeLn(' bw list items --search google --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2');
writeLn(' bw list items --url https://google.com');
writeLn(' bw list items --folderid null');
writeLn(' bw list items --organizationid notnull');
writeLn(' bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2 --organizationid notnull');

View File

@@ -1,11 +1,8 @@
import { DeviceType } from 'jslib/enums/deviceType';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { Utils } from 'jslib/misc/utils';
// tslint:disable-next-line
const pjson = require('../../package.json');
@@ -78,10 +75,6 @@ export class NodePlatformUtilsService implements PlatformUtilsService {
return null as string;
}
getDomain(uriString: string): string {
return Utils.getHostname(uriString);
}
isViewOpen() {
return false;
}