forked from fingerpich/jalali-moment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·28 lines (24 loc) · 948 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
var program = require("commander");
// var inquirer = require("inquirer");
var package = require("./package.json");
var jm = require("./jalali-moment.js");
program
.version(package.version, "-v, --version");
program
.command("togregorian <date>")
.description("convert jalali date to gregorian")
.option("-f, --format", "input format")
.option("-o, --oformat", "output format")
.action(function (date, cmd) {
console.log(jm.from(date, "fa", cmd.readFormat || "YYYY/MM/DD").format(cmd.outformat || "YYYY/MM/DD"));
});
program
.command("tojalali <date>")
.description("convert a gregorian date to jalali")
.option("-f, --format", "input format")
.option("-o, --oformat", "output format")
.action(function (date, cmd) {
console.log(jm(date, cmd.readFormat || "YYYY/MM/DD").locale("fa").format(cmd.outformat || "YYYY/MM/DD"));
});
program.parse(process.argv);