Skip to content

Commit

Permalink
example flag for a cli command
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-107 committed Jan 6, 2025
1 parent 6ba0a66 commit 905d9ce
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# codebase-stats-cli
CLI wrapper around https://github.com/anton-107/codebase-stats-collector

CLI wrapper around https://github.com/anton-107/codebase-stats-collector

## Usage

```
npm run cli -- knowledge-gaps <PATH TO GIT REPO> --ignoreFiles /path/to/ignored/folder
```
npm run cli -- knowledge-gaps
```
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ module.exports = {
testEnvironment: "node",
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/dist/"],
};

50 changes: 33 additions & 17 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
import { cli, command } from "cleye";

export class CommandLineInterface {
constructor() {}
public run() {
cli({
commands: [
command(
{
name: "knowledge-gaps",
parameters: ["[prompt]"],
},
async () => {
console.log("Calculating files with least number of contributors");
},
),
],
});
}
}
constructor() {}
public run() {
cli({
commands: [
command(
{
name: "knowledge-gaps",
parameters: ["<path to repository>"],
flags: {
ignoreFiles: {
type: String,
description: "Which files to ignore in the output",
},
},
},
async (argv) => {
const repo = argv._.pathToRepository;
console.log(
"Calculating files with least number of contributors",
repo,
);
if (argv.flags.ignoreFiles) {
console.log(
"will ignore the following files in the output: ",
argv.flags.ignoreFiles,
);
}
},
),
],
});
}
}
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {CommandLineInterface} from "./cli";
import { CommandLineInterface } from "./cli";

new CommandLineInterface().run();
new CommandLineInterface().run();

0 comments on commit 905d9ce

Please sign in to comment.