#! /usr/bin/env node
'use strict';

const { Command, Option } = require('commander');

const Revision = require('../lib/utils/revision');
const modeList = Object.values(Revision.REVISION_TYPE);

const program = new Command();
const usage = `[options]

Gets the current or next suggested revision for the project

Example usage:
  $ client-publish revision --mode git-tag --next`;

const modeOption = new Option('-m, --mode <mode>', 'the way to get the revision');
const nextOption = new Option('-n, --next', 'get the next revision based on conventional commit messages');

program
  .name('client-publish revision')
  .usage(usage)
  .addOption(modeOption.choices(modeList).default('timestamp'))
  .addOption(nextOption.default(false))
  .parse(process.argv);

const revision = async (program) => {
  const options = program.opts();
  const mode = options.mode;
  const next = options.next;

  if (!modeList.includes(mode)) {
    console.error(`! Invalid mode "${mode}". Mode must be (${modeList.join('|')}). Exiting.`);
    process.exit(1);
  }

  const revision = next ? await Revision.getNext(mode) : Revision.get(mode);
  console.log(revision);
};

revision(program);

@@ -137,19 +137,19 @@
 ;%0Aconst 
-mod
+typ
 eList = 
@@ -351,19 +351,19 @@
 ision --
-mod
+typ
 e git-ta
@@ -380,19 +380,19 @@
 %0A%0Aconst 
-mod
+typ
 eOption 
@@ -410,22 +410,22 @@
 n('-
-m
+t
 , --
-mode %3Cmod
+type %3Ctyp
 e%3E',
@@ -638,19 +638,19 @@
 dOption(
-mod
+typ
 eOption.
@@ -657,19 +657,19 @@
 choices(
-mod
+typ
 eList).d
@@ -834,19 +834,19 @@
   const 
-mod
+typ
 e = opti
@@ -849,19 +849,19 @@
 options.
-mod
+typ
 e;%0A  con
@@ -892,19 +892,19 @@
 %0A  if (!
-mod
+typ
 eList.in
@@ -910,19 +910,19 @@
 ncludes(
-mod
+typ
 e)) %7B%0A  
@@ -952,27 +952,27 @@
 lid 
-mod
+typ
 e %22$%7B
-mod
+typ
 e%7D%22. 
-Mod
+Typ
 e mu
@@ -980,19 +980,19 @@
 t be ($%7B
-mod
+typ
 eList.jo
@@ -1089,19 +1089,19 @@
 getNext(
-mod
+typ
 e) : Rev
@@ -1114,11 +1114,11 @@
 get(
-mod
+typ
 e);%0A

rename most option for revision to type