Skip to content

Commit

Permalink
add command description
Browse files Browse the repository at this point in the history
  • Loading branch information
solaoi committed Mar 30, 2022
1 parent d8dd691 commit c361c93
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ you can download a binary release
```sh
# Install with wget or curl
## set the latest version on releases.
VERSION=v1.0.20
VERSION=v1.0.21
## case you use wget
wget https://github.com/solaoi/colc/releases/download/$VERSION/colc_linux_amd64.tar.gz
## case you use curl
Expand Down
28 changes: 26 additions & 2 deletions colc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@ import {
import { runner } from "./lib/common.ts";
import { parse } from "https://deno.land/[email protected]/flags/mod.ts";

const { _, binsize, b, filter, f, check, c, precision, p } = parse(Deno.args);
const colcVersion = "v1.0.21"
const colcDescription = `Complete documentation is available at https://github.com/solaoi/colc
Usage:
colc [column] [file.csv|tsv|txt]
Options:
-c,--check : check the column is valid
-p,--precision <number> : set precision, default is 6
-b,--binsize <number> : show frequency table and histogram
-f,--filter <number(1-99)> : with binsize option, filter frequency
-v,--version : show version
-h,--help : show help`

const { _, binsize, b, filter, f, check, c, precision, p, help,h,version,v } = parse(Deno.args);
const [column, filename] = _;
const hasTwoColumn = (() => {
if (typeof column !== "string") return false;
Expand All @@ -18,10 +32,20 @@ const hasTwoColumn = (() => {
Number.isInteger(parseInt(columns[1]));
})();

if(h !== undefined || help !== undefined ){
console.log(colcDescription);
Deno.exit(0);
}

if(v !== undefined || version !== undefined ){
console.log(colcVersion);
Deno.exit(0);
}

if (
(typeof column !== "number" && !hasTwoColumn) || typeof filename !== "string"
) {
console.log("Usage:\n colc [column] [file.csv|tsv|txt]");
console.log(colcDescription);
Deno.exit(1);
}
const awkPrecision: number = (() => {
Expand Down

0 comments on commit c361c93

Please sign in to comment.