* '''ng new''': Generates a new Angular application. * '''ng generate''': Creates new components, services, modules, and other Angular constructs. * '''ng serve''': Serves the application locally for development and testing. * '''ng build''': Builds the application for deployment. * '''ng test''': Runs unit tests. * '''ng e2e''': Runs end-to-end tests.
* '''Project Scaffolding''': Quickly sets up a new Angular project with best practices. * '''Code Generation''': Automates the creation of Angular components, services, and other code structures. * '''Development Server''': Provides a live-reload development server. * '''Testing Tools''': Integrates unit and end-to-end testing capabilities. * '''Build Optimization''': Produces optimized builds for deployment.
```bash ng new my-angular-app ```
```bash ng generate component my-component ```
```bash ng serve ```
```bash ng build --prod ```
```bash ng test ```
```python import subprocess
def run_angular_cli_command(command): result = subprocess.run(command, capture_output=True, text=True) print(result.stdout) if result.stderr: print(f"Error: {result.stderr}")
# Example usage: create a new Angular project run_angular_cli_command(['ng', 'new', 'my-angular-app']) ```
```java import java.io.BufferedReader; import java.io.InputStreamReader;
public class AngularCliExample { public static void runAngularCliCommand(String[] command) { try { Process process = new ProcessBuilder(command).start(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while ((line = reader.readLine()) != null) { System.out.println(line); } reader.close(); int exitCode = process.waitFor(); if (exitCode != 0) { BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); while ((line = errorReader.readLine()) != null) { System.err.println("Error: " + line); } errorReader.close(); } } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) { // Example usage: create a new Angular project runAngularCliCommand(new String[]{"ng", "new", "my-angular-app"}); } } ```