Skip to content

Commit 905d9ce

Browse files
committed
example flag for a cli command
1 parent 6ba0a66 commit 905d9ce

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# codebase-stats-cli
2-
CLI wrapper around https://github.com/anton-107/codebase-stats-collector
2+
3+
CLI wrapper around https://github.com/anton-107/codebase-stats-collector
34

45
## Usage
6+
7+
```
8+
npm run cli -- knowledge-gaps <PATH TO GIT REPO> --ignoreFiles /path/to/ignored/folder
59
```
6-
npm run cli -- knowledge-gaps
7-
```

jest.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ module.exports = {
44
testEnvironment: "node",
55
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/dist/"],
66
};
7-

src/cli.ts

+33-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
import { cli, command } from "cleye";
22

33
export class CommandLineInterface {
4-
constructor() {}
5-
public run() {
6-
cli({
7-
commands: [
8-
command(
9-
{
10-
name: "knowledge-gaps",
11-
parameters: ["[prompt]"],
12-
},
13-
async () => {
14-
console.log("Calculating files with least number of contributors");
15-
},
16-
),
17-
],
18-
});
19-
}
20-
}
4+
constructor() {}
5+
public run() {
6+
cli({
7+
commands: [
8+
command(
9+
{
10+
name: "knowledge-gaps",
11+
parameters: ["<path to repository>"],
12+
flags: {
13+
ignoreFiles: {
14+
type: String,
15+
description: "Which files to ignore in the output",
16+
},
17+
},
18+
},
19+
async (argv) => {
20+
const repo = argv._.pathToRepository;
21+
console.log(
22+
"Calculating files with least number of contributors",
23+
repo,
24+
);
25+
if (argv.flags.ignoreFiles) {
26+
console.log(
27+
"will ignore the following files in the output: ",
28+
argv.flags.ignoreFiles,
29+
);
30+
}
31+
},
32+
),
33+
],
34+
});
35+
}
36+
}

src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import {CommandLineInterface} from "./cli";
1+
import { CommandLineInterface } from "./cli";
22

3-
new CommandLineInterface().run();
3+
new CommandLineInterface().run();

0 commit comments

Comments
 (0)