Skip to content

Commit 4fb8376

Browse files
committed
[DATE]: command added
Signed-off-by: ashish <[email protected]>
1 parent 864964c commit 4fb8376

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ USAGE
4949
* [`cdt autocomplete [SHELL]`](#cdt-autocomplete-shell)
5050
* [`cdt bundlephobia [PACKAGE]`](#cdt-bundlephobia-package)
5151
* [`cdt crypto [STRING]`](#cdt-crypto-string)
52+
* [`cdt date [FILE]`](#cdt-date-file)
5253
* [`cdt hash [STRING]`](#cdt-hash-string)
5354
* [`cdt help [COMMAND]`](#cdt-help-command)
5455
* [`cdt minify [FILE]`](#cdt-minify-file)
@@ -112,6 +113,22 @@ OPTIONS
112113

113114
_See code: [src/commands/crypto.ts](https://github.com/codingtools/cdt/blob/v0.1.4/src/commands/crypto.ts)_
114115

116+
## `cdt date [FILE]`
117+
118+
describe the command here
119+
120+
```
121+
USAGE
122+
$ cdt date [FILE]
123+
124+
OPTIONS
125+
-f, --force
126+
-h, --help show CLI help
127+
-n, --name=name name to print
128+
```
129+
130+
_See code: [src/commands/date.ts](https://github.com/codingtools/cdt/blob/v0.1.4/src/commands/date.ts)_
131+
115132
## `cdt hash [STRING]`
116133

117134
Hashing functionality for a string/file

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"crypto-js": "^3.1.9-1",
2424
"jshashes": "^1.0.7",
2525
"minify": "^4.1.3",
26+
"moment": "^2.24.0",
2627
"nyc": "^14.1.1",
2728
"ora": "^4.0.2",
2829
"signale": "^1.4.0",

src/commands/date.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {Command, flags} from '@oclif/command'
2+
3+
export default class Date extends Command {
4+
static description = 'describe the command here'
5+
6+
static flags = {
7+
help: flags.help({char: 'h'}),
8+
// flag with a value (-n, --name=VALUE)
9+
name: flags.string({char: 'n', description: 'name to print'}),
10+
// flag with no value (-f, --force)
11+
force: flags.boolean({char: 'f'}),
12+
}
13+
14+
static args = [{name: 'file'}]
15+
16+
async run() {
17+
const {args, flags} = this.parse(Date)
18+
19+
const name = flags.name || 'world'
20+
this.log(`hello ${name} from /Users/ashish/Desktop/cdt/src/commands/date.ts`)
21+
if (args.file && flags.force) {
22+
this.log(`you input --force and --file: ${args.file}`)
23+
}
24+
}
25+
}

test/commands/date.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {expect, test} from '@oclif/test'
2+
3+
describe('date', () => {
4+
test
5+
.stdout()
6+
.command(['date'])
7+
.it('runs hello', ctx => {
8+
expect(ctx.stdout).to.contain('hello world')
9+
})
10+
11+
test
12+
.stdout()
13+
.command(['date', '--name', 'jeff'])
14+
.it('runs hello --name jeff', ctx => {
15+
expect(ctx.stdout).to.contain('hello jeff')
16+
})
17+
})

0 commit comments

Comments
 (0)