or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli.mdconfiguration.mdcore-api.mddirectives.mdindex.md

cli.mddocs/

0

# Command Line Interface

1

2

RTLCSS provides a comprehensive command-line interface for batch processing CSS files, supporting various input/output methods and configuration options.

3

4

## Capabilities

5

6

### Basic Usage

7

8

Transform CSS files from command line with various input and output options.

9

10

```bash { .api }

11

# Basic file transformation

12

rtlcss input.css output.css

13

14

# Auto-generate output filename (input.rtl.css)

15

rtlcss input.css

16

17

# Process from stdin to stdout

18

cat input.css | rtlcss -

19

20

# Read from stdin, write to file

21

rtlcss - output.css

22

23

# Process directory recursively

24

rtlcss -d input-dir output-dir

25

```

26

27

### Command Line Options

28

29

Complete set of CLI options for controlling RTLCSS behavior.

30

31

```bash { .api }

32

# Help and version

33

rtlcss -h, --help # Display help message

34

rtlcss -v, --version # Display version number

35

36

# Configuration

37

rtlcss -c, --config PATH # Specify configuration file path

38

39

# Input/output options

40

rtlcss -, --stdin # Read from stdin stream

41

rtlcss -d, --directory # Process all *.css files recursively

42

rtlcss -e, --ext EXT # Set output file extension (default: .rtl.css)

43

44

# Processing options

45

rtlcss -s, --silent # Silent mode - suppress warnings and info

46

```

47

48

**Usage Examples:**

49

50

```bash

51

# Display help

52

rtlcss --help

53

54

# Show version

55

rtlcss --version

56

57

# Use custom config file

58

rtlcss -c ./my-rtlcss-config.json styles.css styles.rtl.css

59

60

# Process directory with custom extension

61

rtlcss -d -e .arabic.css ./src/styles ./dist/styles

62

63

# Silent processing

64

rtlcss -s input.css output.css

65

66

# Process from stdin in silent mode

67

cat styles.css | rtlcss -s - > output.rtl.css

68

```

69

70

### Directory Processing

71

72

Process entire directories of CSS files recursively.

73

74

```bash { .api }

75

# Process directory recursively

76

rtlcss -d SOURCE_DIR DEST_DIR

77

78

# Process directory with custom extension

79

rtlcss -d -e .rtl.css SOURCE_DIR DEST_DIR

80

81

# Process current directory

82

rtlcss -d . ./rtl-output

83

```

84

85

**Directory Processing Examples:**

86

87

```bash

88

# Basic directory processing

89

rtlcss -d ./src/css ./dist/css

90

91

# Preserve directory structure

92

# Input: src/css/components/header.css

93

# Output: dist/css/components/header.rtl.css

94

rtlcss -d ./src/css ./dist/css

95

96

# Custom extension

97

rtlcss -d -e .arabic.css ./styles ./arabic-styles

98

99

# Process with config

100

rtlcss -c .rtlcssrc -d ./src ./dist

101

```

102

103

### Configuration File Usage

104

105

Use configuration files with the CLI for consistent processing options.

106

107

```bash { .api }

108

# Use specific config file

109

rtlcss -c CONFIG_FILE input.css output.css

110

111

# Use config with directory processing

112

rtlcss -c CONFIG_FILE -d SOURCE_DIR DEST_DIR

113

```

114

115

**Configuration File Examples:**

116

117

`.rtlcssrc`:

118

```json

119

{

120

"options": {

121

"autoRename": true,

122

"clean": false,

123

"stringMap": [

124

{

125

"name": "theme-names",

126

"search": ["light", "dark"],

127

"replace": ["فاتح", "داكن"],

128

"priority": 100

129

}

130

]

131

}

132

}

133

```

134

135

Usage:

136

```bash

137

rtlcss -c .rtlcssrc styles.css styles.rtl.css

138

```

139

140

### Standard Input/Output Operations

141

142

Process CSS through standard input and output streams.

143

144

```bash { .api }

145

# Read from stdin, write to stdout

146

rtlcss -

147

148

# Read from stdin, write to file

149

rtlcss - output.css

150

151

# Pipe operations

152

cat input.css | rtlcss - > output.css

153

154

# Process with other tools

155

cat input.css | rtlcss - | gzip > output.css.gz

156

```

157

158

**Stdin/Stdout Examples:**

159

160

```bash

161

# Simple pipe

162

echo ".test { float: left; }" | rtlcss -

163

# Output: .test { float: right; }

164

165

# Process multiple files through stdin

166

find ./css -name "*.css" -exec cat {} \; | rtlcss - > combined.rtl.css

167

168

# Integration with build tools

169

webpack --mode production | rtlcss - > bundle.rtl.css

170

171

# Process with preprocessing

172

sass input.scss | rtlcss - > output.rtl.css

173

```

174

175

### Error Handling and Exit Codes

176

177

CLI provides specific exit codes for different error conditions.

178

179

```bash { .api }

180

# Exit codes

181

# 0: Success

182

# 1: Argument error (invalid options, missing files)

183

# 2: Processing error (CSS parsing, transformation errors)

184

```

185

186

**Error Handling Examples:**

187

188

```bash

189

# Check exit code

190

rtlcss input.css output.css

191

echo $? # 0 for success, 1 for argument error, 2 for processing error

192

193

# Handle errors in scripts

194

if rtlcss -c config.json input.css output.css; then

195

echo "RTL conversion successful"

196

else

197

echo "RTL conversion failed with exit code $?"

198

exit 1

199

fi

200

201

# Silent error handling

202

rtlcss -s input.css output.css 2>/dev/null

203

if [ $? -eq 0 ]; then

204

echo "Success"

205

fi

206

```

207

208

### Integration Examples

209

210

Common integration patterns with build tools and workflows.

211

212

**Makefile Integration:**

213

214

```makefile

215

# Makefile

216

.PHONY: rtl

217

rtl:

218

rtlcss -d ./src/css ./dist/css-rtl

219

220

rtl-clean:

221

rtlcss -c .rtlcssrc -d ./src/css ./dist/css-rtl

222

```

223

224

**NPM Scripts:**

225

226

```json

227

{

228

"scripts": {

229

"build:rtl": "rtlcss -d ./src/styles ./dist/styles-rtl",

230

"build:rtl:clean": "rtlcss -c .rtlcssrc -d ./src/styles ./dist/styles-rtl",

231

"watch:rtl": "chokidar './src/styles/**/*.css' -c 'rtlcss {path} ./dist/styles-rtl/{name}.rtl.css'"

232

}

233

}

234

```

235

236

**Shell Script Integration:**

237

238

```bash

239

#!/bin/bash

240

# build-rtl.sh

241

242

set -e

243

244

CONFIG_FILE=".rtlcssrc"

245

SOURCE_DIR="./src/styles"

246

OUTPUT_DIR="./dist/styles-rtl"

247

248

echo "Building RTL stylesheets..."

249

250

if [ -f "$CONFIG_FILE" ]; then

251

rtlcss -c "$CONFIG_FILE" -d "$SOURCE_DIR" "$OUTPUT_DIR"

252

else

253

echo "Warning: No config file found, using defaults"

254

rtlcss -d "$SOURCE_DIR" "$OUTPUT_DIR"

255

fi

256

257

echo "RTL build complete"

258

```

259

260

**CI/CD Integration:**

261

262

```yaml

263

# GitHub Actions example

264

name: Build RTL CSS

265

on: [push]

266

jobs:

267

build-rtl:

268

runs-on: ubuntu-latest

269

steps:

270

- uses: actions/checkout@v2

271

- uses: actions/setup-node@v2

272

with:

273

node-version: '16'

274

- run: npm install rtlcss

275

- run: npx rtlcss -d ./src/css ./dist/css-rtl

276

- run: npx rtlcss -c .rtlcssrc -e .arabic.css ./src/css ./dist/css-arabic

277

```

278

279

### Configuration File Discovery

280

281

CLI automatically searches for configuration files in the following order:

282

283

1. File specified by `-c` option

284

2. `.rtlcssrc` in current directory and parent directories

285

3. `.rtlcss.json` in current directory and parent directories

286

4. `rtlcssConfig` property in `package.json`

287

5. Configuration files in user home directory

288

289

```bash

290

# Automatic config discovery

291

rtlcss input.css output.css # Will find and use .rtlcssrc if present

292

293

# Override automatic discovery

294

rtlcss -c /path/to/specific/config.json input.css output.css

295

```