Skip to content

Commit

Permalink
Merge pull request #2 from yazilimcimekani/first_cmd
Browse files Browse the repository at this point in the history
First cmd
  • Loading branch information
mertssmnoglu authored Apr 23, 2023
2 parents 6b6887d + a69ad91 commit 5131e12
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 23 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
Your CLI Markdown 👨‍⚕️ Doctor

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat&logo=prettier)](https://github.com/prettier/prettier)

## Install

```shell
npm install mdoctor --global
```
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@yazilimcimekani/mdoctor",
"version": "0.0.1-beta",
"name": "mdoctor",
"version": "0.0.2-beta",
"description": "Your CLI Markdown Doctor",
"main": "src/cli.js",
"main": "bin/mdoctor",
"bin": {
"markdown-doctor": "bin/mdoctor",
"mdoctor": "bin/mdoctor"
Expand Down
24 changes: 12 additions & 12 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
const { clear } = require('./commands/');

module.exports = function cli(args) {
this.version = 'Version 0.0.1-beta';
const { version } = require('./commands/');

function cli(args) {
const commands = [
{
name: 'clear',
description: 'Clears the console',
run: clear
name: 'version',
description: 'Shows the version',
run: version
}
];
let userArgs = args.slice(2);
let usedCommand = commands.filter(function (command) {
return command.name === userArgs[0];
})[0];

if (!usedCommand)
return console.log(
`Can't find command with name ${userArgs[0] ? userArgs[0] : 'null'}`
);
if (!usedCommand && (userArgs[0] == '--version' || userArgs[0] == '-v'))
return commands[0].run();
else if (!usedCommand) return;

usedCommand.run();
};
}

module.exports = cli;
3 changes: 0 additions & 3 deletions src/commands/clear.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/commands/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
clear: require('../commands/clear')
version: require('../commands/version')
};
4 changes: 4 additions & 0 deletions src/commands/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function version() {
this.version = 'Version: 0.0.2-beta';
console.log(this.version);
};

0 comments on commit 5131e12

Please sign in to comment.