Skip to content

Commit 6b44408

Browse files
authored
Merge pull request #3 from msoghoian/search
Add support for docker search command
2 parents e494486 + 9cf2345 commit 6b44408

4 files changed

Lines changed: 50 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ my_config.json
3232
.DS_Store
3333
npm-debug.log
3434
dist
35+
36+
# IDE Configuration files
37+
.idea

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,35 @@ docker.command('info').then(function (data) {
549549
// registry: 'https://index.docker.io/v1/' } }
550550
```
551551

552+
* docker search
553+
554+
```js
555+
docker.command('search nginxcont').then(function (data) {
556+
console.log('data = ', data);
557+
});
558+
559+
// data = {
560+
// command: 'docker search nginxcont ',
561+
// raw:
562+
// 'NAME DESCRIPTION STARS OFFICIAL AUTOMATED\nprotonyx76/nginxcontainer 0 \nddavie2323/nginxhelloworld NGINXContainer 0 \n',
563+
// images:
564+
// [{
565+
// name: 'protonyx76/nginxcontainer',
566+
// description: '',
567+
// stars: '0',
568+
// official: '',
569+
// automated: ''
570+
// },
571+
// {
572+
// name: 'ddavie2323/nginxhelloworld',
573+
// description: 'NGINXContainer',
574+
// stars: '0',
575+
// official: '',
576+
// automated: ''
577+
// }]
578+
// }
579+
```
580+
552581
## License
553582

554583
MIT

src/index.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,14 @@ test('docker-cli-js', t => {
8585
});
8686
});
8787

88+
t.test('search', t => {
89+
90+
let docker = new Docker();
91+
92+
return docker.command('search nginxcont').then(function (data) {
93+
console.log('data = ', data);
94+
t.ok(data.images);
95+
});
96+
});
97+
8898
});

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,16 @@ const extractResult = function (result: any) {
117117
return resultp;
118118
},
119119
},
120+
{
121+
re: / search /,
122+
run: function (resultp: any) {
123+
const lines = splitLines(resultp.raw);
120124

125+
resultp.images = cliTable2Json(lines);
121126

122-
127+
return resultp;
128+
},
129+
},
123130
];
124131

125132
extracterArray.forEach(function (extracter) {

0 commit comments

Comments
 (0)