Skip to content

Commit 01bb819

Browse files
committed
[ISSUE#21]: refactor
Signed-off-by: ashish <[email protected]> Signed-off-by: ashish <[email protected]>
1 parent 728b3b2 commit 01bb819

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/commands/crypto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as CryptoJS from 'crypto-js'
33

44
import Logger from '../utilities/logger'
55

6-
import Hash from './hash'
6+
import Utilities from '../utilities/utilities'
77

88
export default class Crypto extends Command {
99
static ENCRYPTION = 'encryption'
@@ -25,7 +25,7 @@ export default class Crypto extends Command {
2525
async run() {
2626
const {args, flags} = this.parse(Crypto)
2727

28-
args.string = Hash.getInputString(this, flags, args) //always add input to args
28+
args.string = Utilities.getInputString(this, flags, args) //always add input to args
2929
args.type = flags.encryption ? flags.encryption : flags.decryption //type like AES,DES
3030

3131
this.checkParameters(flags, args)

src/utilities/utilities.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,16 @@ export default class Utilities {
2727
}
2828
}
2929

30+
public static getInputString(thisRef: any , flags: any, args: any) { //need to make it static so Crypto can use this
31+
// if -s or -f is not passed we will take it from args
32+
if (flags.string) //if -s given
33+
return flags.string
34+
else if (flags.file) {
35+
Logger.info(thisRef, `reading file: ${flags.file}`)
36+
return Utilities.getStringFromFile(thisRef, flags.file)
37+
} else
38+
return args.string
39+
}
40+
41+
3042
}

0 commit comments

Comments
 (0)