or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli.mdconfiguration.mdcss.mdhtml.mdindex.mdjavascript.md
tile.json

cli.mddocs/

0

# Command Line Interface

1

2

Command-line tools for each beautifier supporting file processing, glob patterns, and configuration files. Provides comprehensive CLI access to all beautification features with support for stdin/stdout processing and batch operations.

3

4

## Capabilities

5

6

### JavaScript CLI Binary

7

8

Command-line interface for JavaScript beautification with file processing and configuration support.

9

10

```bash { .api }

11

# Basic usage

12

js-beautify [options] <file1> [file2] ...

13

14

# Common CLI options

15

js-beautify -f file.js # Beautify specific file

16

js-beautify -f file1.js file2.js # Multiple files

17

js-beautify -r -f *.js # Replace files in-place

18

js-beautify -o output.js -f input.js # Write to output file

19

js-beautify < input.js > output.js # Stdin/stdout processing

20

js-beautify --config .jsbeautifyrc -f file.js # Use config file

21

22

# CLI Options:

23

-f, --file Input file(s) (Pass '-' for stdin)

24

-r, --replace Write output in-place, replacing input

25

-o, --outfile Write output to file (default stdout)

26

--config Path to config file

27

--type [js|css|html] Select beautifier type

28

-q, --quiet Suppress logging to stdout

29

-h, --help Show help

30

-v, --version Show version

31

```

32

33

### CSS CLI Binary

34

35

Command-line interface for CSS beautification.

36

37

```bash { .api }

38

# Basic usage

39

css-beautify [options] <file1> [file2] ...

40

41

# Examples

42

css-beautify -f styles.css

43

css-beautify -r -f *.css # In-place replacement

44

css-beautify -s 2 -f input.css # 2-space indentation

45

css-beautify --brace-style expand -f style.css

46

```

47

48

### HTML CLI Binary

49

50

Command-line interface for HTML beautification with template support.

51

52

```bash { .api }

53

# Basic usage

54

html-beautify [options] <file1> [file2] ...

55

56

# Examples

57

html-beautify -f index.html

58

html-beautify -r -f *.html # Batch processing

59

html-beautify --wrap-attributes force -f template.html

60

html-beautify --templating handlebars -f template.hbs

61

```

62

63

## Universal CLI Options

64

65

### File Processing Options

66

67

```bash { .api }

68

# Input/Output

69

-f, --file FILE Input file(s), use '-' for stdin

70

-r, --replace Write output in-place, replacing input files

71

-o, --outfile FILE Write output to specific file (default: stdout)

72

73

# Configuration

74

--config FILE Path to JSON configuration file

75

--type TYPE Force beautifier type [js|css|html]

76

77

# Output Control

78

-q, --quiet Suppress logging output

79

-h, --help Show help message

80

-v, --version Show version information

81

```

82

83

**Usage Examples:**

84

85

```bash

86

# Process stdin to stdout

87

echo 'function test(){return 1;}' | js-beautify

88

89

# Process file to stdout

90

js-beautify -f ugly.js

91

92

# Process multiple files, output to stdout

93

js-beautify -f file1.js file2.js

94

95

# Replace files in-place

96

js-beautify -r -f *.js

97

98

# Use custom output file

99

js-beautify -f input.js -o beautified.js

100

101

# Quiet mode (no progress output)

102

js-beautify -q -f file.js

103

```

104

105

## Beautifier Options

106

107

### JavaScript CLI Options

108

109

```bash { .api }

110

# Indentation

111

-s, --indent-size SIZE Indentation size [4]

112

-c, --indent-char CHAR Indentation character [" "]

113

-t, --indent-with-tabs Indent with tabs, overrides -s and -c

114

-l, --indent-level LEVEL Initial indentation level [0]

115

116

# Line endings

117

-e, --eol STRING Character(s) to use as line terminators

118

-n, --end-with-newline End output with newline

119

--editorconfig Use EditorConfig to set up options

120

121

# Newlines and whitespace

122

-p, --preserve-newlines Preserve line-breaks (--no-preserve-newlines disables)

123

-m, --max-preserve-newlines N Number of line-breaks to preserve in one chunk [10]

124

-w, --wrap-line-length N Wrap lines that exceed N characters [0]

125

--indent-empty-lines Keep indentation on empty lines

126

127

# JavaScript-specific

128

-P, --space-in-paren Add padding spaces within paren, ie. f( a, b )

129

-E, --space-in-empty-paren Add single space inside empty paren, ie. f( )

130

-j, --jslint-happy Enable jslint-stricter mode

131

-a, --space-after-anon-function Add space before anonymous function's parens

132

--space-after-named-function Add space before named function's parens

133

-b, --brace-style STYLE Brace style [collapse|expand|end-expand|none][,preserve-inline]

134

-u, --unindent-chained-methods Don't indent chained method calls

135

-B, --break-chained-methods Break chained method calls across subsequent lines

136

-k, --keep-array-indentation Preserve array indentation

137

-x, --unescape-strings Decode printable characters encoded in xNN notation

138

-X, --e4x Pass E4X xml literals through untouched

139

-C, --comma-first Put commas at beginning of new line instead of end

140

-O, --operator-position POS Set operator position (before-newline|after-newline|preserve-newline)

141

--good-stuff Warm the cockles of Crockford's heart

142

--templating LANGS List of templating languages (auto,django,erb,handlebars,php,smarty,angular)

143

```

144

145

### CSS CLI Options

146

147

```bash { .api }

148

# Basic formatting

149

-s, --indent-size SIZE Indentation size [4]

150

-c, --indent-char CHAR Indentation character [" "]

151

-t, --indent-with-tabs Indent with tabs, overrides -s and -c

152

-e, --eol STRING Character(s) to use as line terminators

153

-n, --end-with-newline End output with newline

154

155

# CSS-specific

156

-b, --brace-style STYLE Brace style [collapse|expand]

157

-L, --selector-separator-newline Add newline between multiple selectors

158

-N, --newline-between-rules Add newline between CSS rules

159

--indent-empty-lines Keep indentation on empty lines

160

```

161

162

### HTML CLI Options

163

164

```bash { .api }

165

# Basic formatting

166

-s, --indent-size SIZE Indentation size [4]

167

-c, --indent-char CHAR Indentation character [" "]

168

-t, --indent-with-tabs Indent with tabs, overrides -s and -c

169

-e, --eol STRING Character(s) to use as line terminators

170

-n, --end-with-newline End output with newline

171

172

# Newlines

173

-p, --preserve-newlines Preserve existing line-breaks

174

-m, --max-preserve-newlines N Maximum number of line-breaks to preserve [10]

175

176

# HTML structure

177

-I, --indent-inner-html Indent <head> and <body> sections

178

-b, --brace-style STYLE Brace style [collapse-preserve-inline|collapse|expand|end-expand|none]

179

-S, --indent-scripts MODE Script indentation [keep|separate|normal]

180

181

# Line wrapping

182

-w, --wrap-line-length N Maximum characters per line (0 disables) [250]

183

-A, --wrap-attributes MODE Wrap attributes to new lines [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]

184

-M, --wrap-attributes-min-attrs N Minimum attributes for force wrap [2]

185

-i, --wrap-attributes-indent-size N Indent wrapped attributes to after N characters

186

187

# Element handling

188

-d, --inline TAGS List of tags to be considered inline tags

189

--inline_custom_elements Inline custom elements [true]

190

-U, --unformatted TAGS List of tags that should not be reformatted

191

-T, --content_unformatted TAGS List of tags whose content should not be reformatted

192

-E, --extra_liners TAGS List of tags that should have extra newline before them

193

--unformatted_content_delimiter STR Keep text content together between this string

194

--indent-empty-lines Keep indentation on empty lines

195

--templating LANGS List of templating languages (auto,none,django,erb,handlebars,php,smarty,angular)

196

```

197

198

## Configuration Files

199

200

### JSON Configuration

201

Use JSON files for complex configuration:

202

203

```json

204

{

205

"indent_size": 2,

206

"brace_style": "expand",

207

"preserve_newlines": true,

208

"max_preserve_newlines": 2,

209

"wrap_line_length": 80

210

}

211

```

212

213

**Usage:**

214

```bash

215

js-beautify --config beautify-config.json -f file.js

216

```

217

218

### .jsbeautifyrc Files

219

Automatically loaded from current directory or parent directories:

220

221

```json

222

{

223

"indent_size": 2,

224

"end_with_newline": true,

225

"js": {

226

"brace_style": "expand"

227

},

228

"css": {

229

"newline_between_rules": false

230

},

231

"html": {

232

"wrap_attributes": "force"

233

}

234

}

235

```

236

237

## Batch Processing Examples

238

239

### Process All JavaScript Files

240

```bash

241

# In-place beautification of all JS files

242

find . -name "*.js" -not -path "./node_modules/*" | xargs js-beautify -r

243

244

# Using glob patterns (if shell supports)

245

js-beautify -r -f src/**/*.js

246

```

247

248

### Different Output for Each File Type

249

```bash

250

# Beautify with different settings per file type

251

js-beautify --indent-size 2 --brace-style expand -r -f src/*.js

252

css-beautify --indent-size 4 --newline-between-rules -r -f styles/*.css

253

html-beautify --wrap-attributes force --indent-size 2 -r -f templates/*.html

254

```

255

256

### Pipeline Processing

257

```bash

258

# Process through pipeline

259

curl -s https://example.com/ugly.js | js-beautify | tee beautiful.js

260

261

# Combine with other tools

262

js-beautify -f ugly.js | grep -v "console.log" > clean.js

263

```

264

265

## Error Handling

266

267

### Exit Codes

268

- `0` - Success

269

- `1` - Error during processing

270

- `2` - Invalid command line arguments

271

272

### Error Messages

273

```bash

274

# Invalid brace style

275

js-beautify --brace-style invalid -f file.js

276

# Error: Invalid Option Value: The option 'brace_style' can only be one of...

277

278

# File not found

279

js-beautify -f nonexistent.js

280

# Error: ENOENT: no such file or directory

281

282

# Permission denied

283

js-beautify -r -f /root/protected.js

284

# Error: EACCES: permission denied

285

```

286

287

### Debugging

288

```bash

289

# Enable debug output

290

DEBUG_JSBEAUTIFY=1 js-beautify -f file.js

291

292

# Or use environment variable

293

export JSBEAUTIFY_DEBUG=1

294

js-beautify -f file.js

295

```