Skip to content

Commit

Permalink
Add RatOS CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Jan 4, 2024
1 parent ce33cc0 commit c8ff2d8
Show file tree
Hide file tree
Showing 22 changed files with 1,804 additions and 335 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"],
["twMerge\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"],
["twJoin\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
]
],
"prettier.requireConfig": true
}
8 changes: 0 additions & 8 deletions src/.prettierrc

This file was deleted.

6 changes: 6 additions & 0 deletions src/bin/ratos
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
RATOS_BIN_CWD=$(pwd)
export RATOS_BIN_CWD
pnpm run --silent -C "$SCRIPT_DIR"/.. cli "$@"
exit $?
10 changes: 10 additions & 0 deletions src/cli/components/container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Box } from 'ink';
import React from 'react';

export const Container: React.FC<React.PropsWithChildren> = (props) => {
return (
<Box padding={2} flexDirection="column">
{props.children}
</Box>
);
};
37 changes: 37 additions & 0 deletions src/cli/components/status.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Box, Text } from 'ink';
import React from 'react';

interface APIResult {
result: 'success' | 'error';
message: string;
}

interface StatusProps {
results: APIResult | APIResult[];
}

export const Status: React.FC<StatusProps> = (props) => {
const hasError = Array.isArray(props.results)
? props.results.some((result) => result.result === 'error')
: props.results.result === 'error';
const results = Array.isArray(props.results) ? props.results : [props.results];
return (
<Box flexDirection="column">
{hasError ? <Text color="red">Error!</Text> : <Text color="green">Success!</Text>}
{results.map(({ message, result }) => (
<Box key={message}>
{result === 'success' ? (
<Text color="green" bold={true}>
{' '}
</Text>
) : (
<Text color="red" bold={true}>
{' '}
</Text>
)}
<Text dimColor>{message}</Text>
</Box>
))}
</Box>
);
};
Loading

0 comments on commit c8ff2d8

Please sign in to comment.