Skip to content

Commit

Permalink
📦 NEW: All option
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Apr 24, 2020
1 parent 5eaea8a commit f4464f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ const green = string => chalk.hex(`#81EF96`)(string);

// CLI.
const [input] = cli.input;
const option = cli.flags.option;
const all = cli.flags.all;

(async () => {
init();
input === 'help' && (await cli.showHelp(0));
const firstRoza = '2020-04-25';
const today = new Date().toISOString().substring(0, 10);
const rozaNumber = dateDiff(firstRoza, '2020-06-10');
const rozaNumber = dateDiff(firstRoza, today);
if (rozaNumber > 30) {
console.log(
`${sym.success} Eid Mubarak.\nRamadan is already over. Hope you had a fun time on Eid.\n`
Expand All @@ -32,7 +33,11 @@ const option = cli.flags.option;
head: [green('Roza'), green('Sehar'), green('Iftar')]
});

table.push([roza.no, roza.sehar, roza.iftar]);
if (all) {
data.map(day => table.push([day.no, day.sehar, day.iftar]));
} else {
table.push([roza.no, roza.sehar, roza.iftar]);
}
console.log(table.toString());
}
theEnd();
Expand Down
15 changes: 6 additions & 9 deletions utils/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,24 @@ module.exports = meow(
${green(`ramadan-cli`)} ${cyan(`<command>`)} ${yellow(`[--option]`)}
Commands
${cyan(`command`)} Description
${cyan(`help`)} Show help
Options
${yellow(`--option`)}, ${yellow(`-o`)} Description
${yellow(`--all`)}, ${yellow(`-a`)} Show all days
Examples
${green(`ramadan-cli`)} ${cyan(`command`)}
${green(`ramadan-cli`)} ${yellow(`--option`)}
❯ You can also run command + option at once:
${green(`ramadan-cli`)} ${cyan(`command`)} ${yellow(`-o`)}
${green(`ramadan-cli`)} ${yellow(`--all`)}
${green(`ramadan-cli`)} ${cyan(`help`)}
`,
{
booleanDefault: undefined,
hardRejection: false,
inferType: false,
flags: {
option: {
all: {
type: 'boolean',
default: false,
alias: 'o'
alias: 'a'
}
}
}
Expand Down

0 comments on commit f4464f7

Please sign in to comment.