cli-high
Version:
tiny cli highlighter
3 lines (2 loc) • 3.04 kB
JavaScript
;const l=require("node:path"),p=require("node:fs/promises"),r=require("node:process"),helpers=require("yargs/helpers"),g=require("yargs"),prompts=require("@clack/prompts"),xycolors=require("xycolors"),index=require("./index.cjs");require("sugar-high");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const l__default=_interopDefaultCompat(l),p__default=_interopDefaultCompat(p),r__default=_interopDefaultCompat(r),g__default=_interopDefaultCompat(g),name="cli-high",version="0.4.3",description="tiny cli highlighter",type="module",keywords=["cli","highlighter","highlight","color","terminal","console"],license="MIT",homepage="https://github.com/xinyao27/cli-high#readme",bugs={url:"https://github.com/xinyao27/cli-high/issues"},repository={type:"git",url:"git+https://github.com/xinyao27/cli-high.git"},author={name:"xinyao",email:"hi@xinyao.me"},funding="https://github.com/sponsors/xinyao27",files=["bin/*","dist/*","package.json"],main="./dist/index.cjs",module$1="./dist/index.mjs",types="./dist/index.d.ts",exports$1={".":{types:"./dist/index.d.ts",require:"./dist/index.cjs",import:"./dist/index.mjs"}},sideEffects=!1,bin="./bin/index.js",scripts={build:"unbuild",stub:"unbuild --stub",typecheck:"tsc --noEmit",lint:"nr typecheck && eslint . --fix",prepublishOnly:"nr build",release:"release-it",start:"bun run src/index.ts",test:"bun test",up:"taze major -I",prepare:"husky"},dependencies={"@clack/prompts":"^0.7.0","sugar-high":"^0.7.1",xycolors:"^0.1.2",yargs:"^17.7.2"},devDependencies={"@antfu/ni":"^0.23.0","@commitlint/cli":"^19.5.0","@release-it/conventional-changelog":"^9.0.0","@types/bun":"^1.1.11","@types/yargs":"^17.0.33","@xystack/style-guide":"^0.2.4",commitizen:"^4.3.1","cz-conventional-changelog":"^3.3.0",eslint:"^9.12.0",husky:"^9.1.6","lint-staged":"^15.2.10",prettier:"^3.3.3","release-it":"^17.9.0",taze:"^0.17.2",typescript:"^5.6.3",unbuild:"^2.0.0"},prettier="@xystack/style-guide/prettier",e={name,version,description,type,keywords,license,homepage,bugs,repository,author,funding,files,main,module:module$1,types,exports:exports$1,sideEffects,bin,scripts,dependencies,devDependencies,prettier};function S(){console.log(`
`),prompts.intro(`\u2728 ${xycolors.magentaStylize(`${e.name} `)}${xycolors.dim(`v${e.version}`)}`)}const $=g__default(helpers.hideBin(r__default.argv)).scriptName("cli-high").usage("").command("*","Outputs a file or STDIN input with syntax highlighting",t=>t.option("showLineNumbers",{alias:"s",description:"Show line numbers",type:"boolean"}).help(),async t=>{const{_:s,showLineNumbers:n}=t;S();try{const i=l__default.join(r__default.cwd(),s[0].toString()),o=await p__default.readFile(i,"utf-8"),c=index.highlight(o,{showLineNumbers:n});prompts.note(c)}catch(i){prompts.log.error(xycolors.inverse(xycolors.redStylize(" Failed to read file"))),prompts.log.error(xycolors.redStylize(`\u2718 ${String(i)}`)),r__default.exit(1)}}).showHelpOnFail(!1).alias("h","help").version("version",e.version).alias("v","version");$.help().argv;