Skip to content

Commit

Permalink
Clean up the project
Browse files Browse the repository at this point in the history
  • Loading branch information
siokas committed Jul 29, 2021
1 parent 4664e51 commit 119b3c4
Show file tree
Hide file tree
Showing 32 changed files with 599 additions and 789 deletions.
3 changes: 0 additions & 3 deletions .lizard_installer.ts

This file was deleted.

7 changes: 0 additions & 7 deletions bootstrap.ts

This file was deleted.

27 changes: 14 additions & 13 deletions docs.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/** Export every available functionality to generate the docs from "https://doc.deno.land" */
export { Arguments } from "./src/Arguments.ts";
export { Command } from "./src/Command.ts";
export { Denomander } from "./src/Denomander.ts";
export { Executor } from "./src/Executor.ts";
export { Helper } from "./src/Helper.ts";
export { Kernel } from "./src/Kernel.ts";
export { Util } from "./src/Util.ts";
export { Validator } from "./src/Validator.ts";
export { Option } from "./src/Option.ts";
export { Container } from "./src/Container.ts";
export { Lizard } from "./src/Lizard.ts";
export * from "./src/interfaces.ts";
export * from "./src/types.ts";
export * as Command from "./src/Command.ts";
export * as Arguments from "./src/Arguments.ts";
export * as Denomander from "./src/Denomander.ts";
export * as Executor from "./src/Executor.ts";
export * as Kernel from "./src/Kernel.ts";
export * as Validator from "./src/Validator.ts";
export * as Option from "./src/Option.ts";
export * from "./src/types/interfaces.ts";
export * from "./src/types/types.ts";
export * from "./src/utils/detect.ts";
export * from "./src/utils/find.ts";
export * from "./src/utils/print.ts";
export * from "./src/utils/set.ts";
export * from "./src/utils/utils.ts";
30 changes: 0 additions & 30 deletions lizard.ts

This file was deleted.

6 changes: 0 additions & 6 deletions lizard_installer.sh

This file was deleted.

6 changes: 3 additions & 3 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Denomander } from "./src/Denomander.ts";
export { CustomOption as Option } from "./src/CustomOption.ts";
export { error_log, success_log, warning_log } from "./src/Logger.ts";
import Denomander from "./src/Denomander.ts";
export * as Option from "./src/CustomOption.ts";
export { error_log, success_log, warning_log } from "./src/utils/print.ts";

export default Denomander;
6 changes: 3 additions & 3 deletions src/Arguments.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { parse } from "../deps.ts";
import { ArgumentsContract } from "./interfaces.ts";
import { CustomArgs } from "./types.ts";
import { ArgumentsContract } from "./types/interfaces.ts";
import { CustomArgs } from "./types/types.ts";

/** It parses the arguments and splits them into commands and options */
export class Arguments implements ArgumentsContract {
export default class Arguments implements ArgumentsContract {
/** Aruments from Deno.args (unparsed) */
protected unparsed_args: Array<string>;

Expand Down
33 changes: 21 additions & 12 deletions src/Command.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { Helper } from "./Helper.ts";
import {
removeBrackets,
removeDashes,
removeQuestionMark,
} from "./utils/remove.ts";
import {
itContainsBrackets,
itContainsCurlyBrackets,
itContainsQuestionMark,
} from "./utils/detect.ts";
import {
CommandArgument,
CommandOption,
CommandParams,
OptionParameters,
} from "./types.ts";
import { Option } from "./Option.ts";
import { CustomOption } from "./CustomOption.ts";
} from "./types/types.ts";
import Option from "./Option.ts";
import CustomOption from "./CustomOption.ts";

/* Command class */
export class Command {
export default class Command {
public declaration = "";
/** If the command has a required value to be passed from the user*/
public require_command_value = false;
Expand Down Expand Up @@ -133,26 +142,26 @@ export class Command {
const splitedValue = this.params.value.split(" ");

if (splitedValue.length == 1) {
this._word_command = Helper.stripDashes(splitedValue[0]);
this._word_command = removeDashes(splitedValue[0]);
} else {
this._word_command = Helper.stripDashes(splitedValue[0]);
this._word_command = removeDashes(splitedValue[0]);
splitedValue.splice(0, 1);
splitedValue.forEach((value) => {
if (Helper.containsBrackets(value)) {
if (itContainsBrackets(value)) {
// Command Here
if (Helper.containsQuestionMark(value)) {
if (itContainsQuestionMark(value)) {
this.command_arguments.push({
argument: Helper.stripBrackets(Helper.stripQuestionMark(value)),
argument: removeBrackets(removeQuestionMark(value)),
isRequired: false,
});
} else {
this.command_arguments.push({
argument: Helper.stripBrackets(value),
argument: removeBrackets(value),
isRequired: true,
});
}
}
if (Helper.containsCurlyBrackets(value)) {
if (itContainsCurlyBrackets(value)) {
// Options Here
}
});
Expand Down
18 changes: 0 additions & 18 deletions src/Container.ts

This file was deleted.

14 changes: 7 additions & 7 deletions src/CustomOption.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CommandOption } from "./types.ts";
import { CommandOption } from "./types/types.ts";

/**
* Class that only handles the custom option form the user
* (it is not used but it reasign the proper Option object)
*
* @export
* @class CustomOption
* Class that only handles the custom option form the user
* (it is not used but it reasign the proper Option object)
*
* @export
* @class CustomOption
*/
export class CustomOption {
export default class CustomOption {
/** Holds the flags as defined (unparsed) */
public _flags: string;

Expand Down
14 changes: 7 additions & 7 deletions src/Denomander.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Arguments } from "./Arguments.ts";
import { Command } from "./Command.ts";
import { Kernel } from "./Kernel.ts";
import { PublicAPI } from "./interfaces.ts";
import { CommandOption, VersionType } from "./types.ts";
import { CustomOption } from "./CustomOption.ts";
import Arguments from "./Arguments.ts";
import Command from "./Command.ts";
import Kernel from "./Kernel.ts";
import CustomOption from "./CustomOption.ts";
import { PublicAPI } from "./types/interfaces.ts";
import { CommandOption, VersionType } from "./types/types.ts";

/** The main class */
export class Denomander extends Kernel implements PublicAPI {
export default class Denomander extends Kernel implements PublicAPI {
/** Parses the args*/
public parse(args: Array<string>) {
this.args = new Arguments(args);
Expand Down
43 changes: 23 additions & 20 deletions src/Executor.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { Arguments } from "./Arguments.ts";
import { Kernel } from "./Kernel.ts";
import { Command } from "./Command.ts";
import { Util } from "./Util.ts";
import { CommandArgument, ValidationRules } from "./types.ts";
import { Helper } from "./Helper.ts";
import { Option } from "./Option.ts";
import { Validator } from "./Validator.ts";
import Arguments from "./Arguments.ts";
import Kernel from "./Kernel.ts";
import Command from "./Command.ts";
import Option from "./Option.ts";
import Validator from "./Validator.ts";
import { CommandArgument, ValidationRules } from "./types/types.ts";
import { isCommandInArgs, isOptionInArgs } from "./utils/detect.ts";
import { findCommandFromArgs, findOptionFromArgs } from "./utils/find.ts";
import { printCommandHelp } from "./utils/print.ts";
import { setOptionValue } from "./utils/set.ts";
import { trimDashesAndSpaces } from "./utils/remove.ts";

/** It is responsible for generating the app variables and running the necessary callback functions */
export class Executor {
export default class Executor {
/** User have the option to throw the errors */
public throw_errors: boolean;

Expand All @@ -29,15 +32,15 @@ export class Executor {
public defaultCommands(): Executor {
if (this.args) {
this.args.commands.forEach((argCommand) => {
const command = Util.findCommandFromArgs(this.app.commands, argCommand);
const command = findCommandFromArgs(this.app.commands, argCommand);

if (command) {
command.options.forEach((option: Option) => {
option.value = Util.setOptionValue(option, this.args!);
option.value = setOptionValue(option, this.args!);

if (Util.optionIsInArgs(option, this.args!)) {
if (isOptionInArgs(option, this.args!)) {
if (option.word_option == "help") {
Util.printCommandHelp(command!);
printCommandHelp(command!);
Deno.exit(0);
}
}
Expand All @@ -59,7 +62,7 @@ export class Executor {
}).validate();

this.args.commands.forEach((arg: string, key: number) => {
const command: Command | undefined = Util.findCommandFromArgs(
const command: Command | undefined = findCommandFromArgs(
this.app.commands,
arg,
);
Expand Down Expand Up @@ -100,7 +103,7 @@ export class Executor {
throw_errors: this.throw_errors,
}).validate();
for (const key in this.args.options) {
const command: Command | undefined = Util.findCommandFromArgs(
const command: Command | undefined = findCommandFromArgs(
this.app.commands,
this.args.commands[0],
);
Expand Down Expand Up @@ -149,22 +152,22 @@ export class Executor {
}).validate();

this.app.on_commands.forEach((onCommand) => {
const command: Command | undefined = Util.findCommandFromArgs(
const command: Command | undefined = findCommandFromArgs(
this.app.commands,
onCommand.arg,
);

const option: Option | undefined = Util.findOptionFromArgs(
const option: Option | undefined = findOptionFromArgs(
this.app.BASE_COMMAND.options,
Helper.noDashesTrimSpaces(onCommand.arg),
trimDashesAndSpaces(onCommand.arg),
);

if (command) {
command.action = onCommand.callback;
this.app.available_actions.push(command);
}

if (option && Util.optionIsInArgs(option, this.args)) {
if (option && isOptionInArgs(option, this.args)) {
if (this.args.options[option.word_option]) {
onCommand.callback(this.args.options[option.word_option]);
}
Expand All @@ -182,7 +185,7 @@ export class Executor {
public actionCommands(): Executor {
this.app.available_actions.forEach((command: Command) => {
if (this.args) {
if (Util.isCommandInArgs(command, this.args)) {
if (isCommandInArgs(command, this.args)) {
if (command.command_arguments.length == 0) {
command.action(this.app);
} else {
Expand Down
42 changes: 0 additions & 42 deletions src/Helper.ts

This file was deleted.

Loading

0 comments on commit 119b3c4

Please sign in to comment.