Qodalis Angular CLI is a web-based terminal CLI component for Angular applications. It provides a powerful and extensible interface to execute commands and streamline workflows directly within your web application. The CLI can be extended with custom command processors to suit your specific needs.
&&
and ||
, allowing you to combine multiple commands in a single execution, similar to how they work in Unix-like shells or scripting environments. This feature enhances productivity by chaining commands with conditional logic.Check out a live example of the Qodalis Angular CLI on StackBlitz
Cli docs link
Install the package using npm:
npm install @qodalis/angular-cli
After installing, you can integrate the CLI component into your Angular application:
import { CliModule } from "@qodalis/angular-cli";
@NgModule({
imports: [CliModule, Cli***Module],
})
export class AppModule {}
{
"projects": {
"your-project": {
"architect": {
"options": {
"styles": [
"node_modules/primeng/resources/primeng.min.css",
"node_modules/primeicons/primeicons.css",
"node_modules/primeng/resources/themes/lara-dark-indigo/theme.css"
"node_modules/@qodalis/angular-cli/src/assets/styles.sass"]
}
}
}
}
}
<!--
Show a terminal
-->
<cli [options]="cliOptions" />
<!--
Show a terminal wrapped in a container that is located at the bottom of the page and can be collapsed/expanded
-->
<cli-panel />
cliOptions = {
welcomeMessage: {
message: "-- your custom welcome message --",
show: "daily", //never, once
},
usersModule: {
enabled: true,
},
};
See the available packages section.
The CLI allows you to install packages directly from the terminal using the packages add
To add a package, use the packages add command:
root:~$ packages add <package-name1> <package-name2> <package-namen>
Example:
root:~$ packages add guid
root:~$ packages add regex
root:~$ packages add string
root:~$ packages add curl
root:~$ packages add <any npm package that support umd>
This command downloads and makes the package available for evaluation.
Remove a package using the packages remove
command:
root:~$ packages remove guid
Update a package using the packages update
command:
root:~$ packages update guid # update 1 package
root:~$ packages update guid todo # update 2 packages
root:~$ packages update # update all packages
packages add guid
guid new # output a19a7be4-8818-41b2-b0c2-1c82f8c21826
guid new -c # copy to the clipboard
guid new --count=3 # output 3 guid's
root:~$ packages add lodash
root:~$ eval _.map([1, 2, 3, 4, 5], (n) => n * 2);
Output:
[
2,
4,
6,
8,
10
]
root:~$
You can extend the CLI by creating a class that implements the ICliCommandProcessor interface. This allows you to define new commands and their behavior.
ICliCommandProcessor
:import { ICliCommandProcessor, CliProcessCommand, ICliExecutionContext } from "@qodalis/angular-cli";
export class MyCustomCommandProcessor implements ICliCommandProcessor {
command = "greet";
description = "Greet the user with a custom message";
allowUnlistedCommands = true;
async processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void> {
const name = command.value;
const message = name ? `Hello, ${name}!` : "Hello!";
context.writer.writeln(message);
}
}
import { CliModule, resolveCommandProcessorProvider } from "@qodalis/angular-cli";
@NgModule({
imports: [CliModule],
providers: [resolveCommandProcessorProvider(MyCustomCommandProcessor)],
})
export class AppModule {}
After registering MyCustomCommandProcessor, you can use the following command:
greet John
Output:
Hello, John!
The CLI is designed with extensibility in mind, allowing you to enhance its functionality through custom extensions. These extensions can be installed directly from npm and seamlessly integrated into your Angular project by adding them to the imports array in your Angular module.
How It Works:
npm install @qodalis/cli-extension-name
import { ExtensionModule } from "@qodalis/cli-extension-name";
@NgModule({
imports: [
CliModule,
ExtensionModule,
// other imports
],
})
export class AppModule {}
Benefits:
These logical operators rely on the exit codes of commands:
0
indicates success.Commands are executed sequentially in the order specified.
Logical operators provide flexibility to handle conditional execution efficiently in automation scripts or complex workflows.
# Example with &&
packages add guid && echo Package installed
# Example with ||
packages add invalid-package || echo Package not installed
We welcome contributions! To contribute:
Please ensure all contributions follow the project coding standards.
This project is licensed under the MIT License. See the LICENSE file for details.
You can copy this content into a file named `README.md` in your project directory. Let me know if there's anything else you'd like to adjust! 🚀