bash-calendar/index.js

5 lines
42 KiB
JavaScript
Raw Normal View History

2023-07-06 10:33:51 +08:00
#!/usr/bin/env node
var K0=Object.create;var l0=Object.defineProperty;var X0=Object.getOwnPropertyDescriptor;var J0=Object.getOwnPropertyNames;var Z0=Object.getPrototypeOf,Q0=Object.prototype.hasOwnProperty;var E=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var e2=(e,r,a,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of J0(r))!Q0.call(e,t)&&t!==a&&l0(e,t,{get:()=>r[t],enumerable:!(n=X0(r,t))||n.enumerable});return e};var Y=(e,r,a)=>(a=e!=null?K0(Z0(e)):{},e2(r||!e||!e.__esModule?l0(a,"default",{value:e,enumerable:!0}):a,e));var c0=E((I2,i0)=>{"use strict";var r2=/[|\\{}()[\]^$+*?.]/g;i0.exports=function(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(r2,"\\$&")}});var f0=E(($2,u0)=>{"use strict";u0.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[
`],["r","\r"],["t"," "],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e","\x1B"],["a","\x07"]]);function S0(e){return e[0]==="u"&&e.length===5||e[0]==="x"&&e.length===3?String.fromCharCode(parseInt(e.slice(1),16)):x2.get(e)||e}function y2(e,r){let a=[],n=r.trim().split(/\s*,\s*/g),t;for(let s of n)if(!isNaN(s))a.push(Number(s));else if(t=s.match(d2))a.push(t[2].replace(b2,(l,i,o)=>i?S0(i):o));else throw new Error(`Invalid Chalk template style argument: ${s} (in style '${e}')`);return a}function m2(e){R0.lastIndex=0;let r=[],a;for(;(a=R0.exec(e))!==null;){let n=a[1];if(a[2]){let t=y2(n,a[2]);r.push([n].concat(t))}else r.push([n])}return r}function O0(e,r){let a={};for(let t of r)for(let s of t.styles)a[s[0]]=t.inverse?null:s.slice(1);let n=e;for(let t of Object.keys(a))if(Array.isArray(a[t])){if(!(t in n))throw new Error(`Unknown Chalk style: ${t}`);a[t].length>0?n=n[t].apply(n,a[t]):n=n[t]}return n}A0.exports=(e,r)=>{let a=[],n=[],t=[];if(r.replace(p2,(s,l,i,o,u,h)=>{if(l)t.push(S0(l));else if(o){let f=t.join("");t=[],n.push(a.length===0?f:O0(e,a)(f)),a.push({inverse:i,styles:m2(o)})}else if(u){if(a.length===0)throw new Error("Found extraneous } in Chalk template literal");n.push(O0(e,a)(t.join(""))),t=[],a.pop()}else t.push(h)}),n.push(t.join("")),a.length>0){let s=`Chalk template literal is missing ${a.length} closing bracket${a.length===1?"":"s"} (\`}\`)`;throw new Error(s)}return n.join("")}});var e0=E((U2,j)=>{"use strict";var Q=c0(),p=w0(),Z=C0().stdout,w2=_0(),L0=process.platform==="win32"&&!(process.env.TERM||"").toLowerCase().startsWith("xterm"),N0=["ansi","ansi","ansi256","ansi16m"],B0=new Set(["gray"]),N=Object.create(null);function T0(e,r){r=r||{};let a=Z?Z.level:0;e.level=r.level===void 0?a:r.level,e.enabled="enabled"in r?r.enabled:e.level>0}function B(e){if(!this||!(this instanceof B)||this.template){let r={};return T0(r,e),r.template=function(){let a=[].slice.call(arguments);return E2.apply(null,[r.template].concat(a))},Object.setPrototypeOf(r,B.prototype),Object.setPrototypeOf(r.template,r),r.template.constructor=B,r.template}T0(this,e)}L0&&(p.blue.open="\x1B[94m");for(let e of Object.keys(p))p[e].closeRe=new RegExp(Q(p[e].close),"g"),N[e]={get(){let r=p[e];return U.call(this,this._styles?this._styles.concat(r):[r],this._empty,e)}};N.visible={get(){return U.call(this,this._styles||[],!0,"visible")}};p.color.closeRe=new RegExp(Q(p.color.close),"g");for(let e of Object.keys(p.color.ansi))B0.has(e)||(N[e]={get(){let r=this.level;return function(){let n={open:p.color[N0[r]][e].apply(null,arguments),close:p.color.close,closeRe:p.color.closeRe};return U.call(this,this._styles?this._styles.concat(n):[n],this._empty,e)}}});p.bgColor.closeRe=new RegExp(Q(p.bgColor.close),"g");for(let e of Object.keys(p.bgColor.ansi)){if(B0.has(e))continue;let r="bg"+e[0].toUpperCase()+e.slice(1);N[r]={get(){let a=this.level;return function(){let t={open:p.bgColor[N0[a]][e].apply(null,arguments),close:p.bgColor.close,closeRe:p.bgColor.closeRe};return U.call(this,this._styles?this._styles.concat(t):[t],this._empty,e)}}}}var k2=Object.defineProperties(()=>{},N);function U(e,r,a){let n=function(){return M2.apply(n,arguments)};n._styles=e,n._empty=r;let t=this;return Object.defineProperty(n,"level",{enumerable:!0,get(){return t.level},set(s){t.level=s}}),Object.defineProperty(n,"enabled",{enumerable:!0,get(){return t.enabled},set(s){t.enabled=s}}),n.hasGrey=this.hasGrey||a==="gray"||a==="grey",n.__proto__=k2,n}function M2(){let e=arguments,r=e.length,a=String(arguments[0]);if(r===0)return"";if(r>1)for(let t=1;t<r;t++)a+=" "+e[t];if(!this.enabled||this.level<=0||!a)return this._empty?"":a;let n=p.dim.open;L0&&this.hasGrey&&(p.dim.open="");for(let t of this._styles.slice().reverse())a=t.open+a.replace(t.closeRe,t.open)+t.close,a=a.replace(/\r?\n/g,`${t.close}$&${t.open}`);return p.dim.open=n,a}function E2(e,r){if(!Array.isArray(r))return[].slice.call(arguments,1).join(" ");let a=[].slice.call(arguments,2),n=[r.raw[0]];for(let t=1;t<r.length;t++)n.push(String(a[t-1]).replace(/[{}\\]/g,"\\$&")),n.push(String(r.raw[t]));return
`),d("\u793A\u4F8B: "),d(" cal "+R.default.grey("# \u4E0D\u5E26\u53C2\u6570\u6253\u5370\u5F53\u524D\u5E74\u6708")),d(" cal -y "+R.default.grey("# -y \u4E0D\u63A5\u53C2\u6570, \u6253\u5370\u5F53\u524D\u5E74\u7684\u6240\u6709\u6708\u4EFD")),d(" cal -y 2000 "+R.default.grey("# \u6253\u5370\u6307\u5B9A\u5E74\u4EFD\u7684\u6240\u6709\u6708\u4EFD")),d(" cal -y 2021 5 "+R.default.grey("# \u6253\u5370\u6307\u5B9A\u5E74\u4EFD, \u6307\u5B9A\u6708\u4EFD")),d(" cal -y 2000 -m 3 "+R.default.grey("# \u540C\u4E0A")),d(" cal -m 5 "+R.default.grey("# \u6253\u5370\u5F53\u524D\u5E74\u4EFD\u7684 \u6307\u5B9A\u6708\u4EFD")),d(' cal -c {"2021.12.11":"\u73ED","2021.12.12":"\u4F11"} '+R.default.grey("# \u5BFC\u5165\u81EA\u5B9A\u4E49\u4F11\u5047\u65E5")),process.exit()}switch(P){case"-y":switch(C.length){case 0:s0(m);break;case 1:case 2:m=+C.shift(),b=+C.shift(),m===m?b<13&&b>0?S(m,b-1):s0(m):console.log("-y \u53C2\u6570\u5F02\u5E38");break;case 3:m=+C.shift(),P=C.shift(),b=+C.pop(),P==="-m"&&b<13&&b>0?S(m,b-1):console.log("-m \u53C2\u6570\u5F02\u5E38");break;default:console.log("-y \u53C2\u6570\u5F02\u5E38");break}break;case"-m":b=+C.shift(),b<13&&b>0?S(m,b-1):console.log("-m \u53C2\u6570\u5F02\u5E38");break;case"-v":d(W0);break;case"-h":j2();break;case"-c":let e=C.shift();if(e)try{JSON.parse(e),z0.default.writeFileSync(I,e),console.log("\u5BFC\u5165\u6210\u529F")}catch{console.log("\u9519\u8BEF\u7684json\u6570\u636E")}else console.log("\u5BFC\u5165\u7684\u6570\u636E\u4E3A\u7A7A");break;default:P?(m=+P,b=+C.shift(),m===m?b<13&&b>0?S(m,b-1):s0(m):console.log("\u53C2\u6570\u5F02\u5E38")):S(m,b);break}process.exit();