bash-calendar/index.js

9 lines
42 KiB
JavaScript
Raw Normal View History

2021-11-26 17:24:37 +08:00
#!/usr/bin/env node
var a2=Object.create;var Y=Object.defineProperty,l2=Object.defineProperties,c2=Object.getOwnPropertyDescriptor,i2=Object.getOwnPropertyDescriptors,u2=Object.getOwnPropertyNames,i0=Object.getOwnPropertySymbols,f2=Object.getPrototypeOf,u0=Object.prototype.hasOwnProperty,h2=Object.prototype.propertyIsEnumerable;var f0=(e,t,n)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h0=(e,t)=>{for(var n in t||(t={}))u0.call(t,n)&&f0(e,n,t[n]);if(i0)for(var n of i0(t))h2.call(t,n)&&f0(e,n,t[n]);return e},d0=(e,t)=>l2(e,i2(t)),d2=e=>Y(e,"__esModule",{value:!0});var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var b2=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of u2(t))!u0.call(e,r)&&r!=="default"&&Y(e,r,{get:()=>t[r],enumerable:!(n=c2(t,r))||n.enumerable});return e},B=e=>b2(d2(Y(e!=null?a2(f2(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var g0=w((J2,b0)=>{"use strict";b0.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
2021-11-30 18:50:37 +08:00
`:`
`)+n,o=r+1,r=e.indexOf(`
`,o)}while(r!==-1);return s+=e.substr(o),s};L0.exports={stringReplaceAll:R2,stringEncaseCRLFWithFirstIndex:S2}});var $0=w((se,P0)=>{"use strict";var A2=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,I0=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,_2=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,T2=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,B2=new Map([["n",`
`],["r","\r"],["t"," "],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e",""],["a","\x07"]]);function F0(e){let t=e[0]==="u",n=e[1]==="{";return t&&!n&&e.length===5||e[0]==="x"&&e.length===3?String.fromCharCode(parseInt(e.slice(1),16)):t&&n?String.fromCodePoint(parseInt(e.slice(2,-1),16)):B2.get(e)||e}function L2(e,t){let n=[],r=t.trim().split(/\s*,\s*/g),o;for(let s of r){let a=Number(s);if(!Number.isNaN(a))n.push(a);else if(o=s.match(_2))n.push(o[2].replace(T2,(c,l,u)=>l?F0(l):u));else throw new Error(`Invalid Chalk template style argument: ${s} (in style '${e}')`)}return n}function j2(e){I0.lastIndex=0;let t=[],n;for(;(n=I0.exec(e))!==null;){let r=n[1];if(n[2]){let o=L2(r,n[2]);t.push([r].concat(o))}else t.push([r])}return t}function N0(e,t){let n={};for(let o of t)for(let s of o.styles)n[s[0]]=o.inverse?null:s.slice(1);let r=e;for(let[o,s]of Object.entries(n))if(!!Array.isArray(s)){if(!(o in r))throw new Error(`Unknown Chalk style: ${o}`);r=s.length>0?r[o](...s):r[o]}return r}P0.exports=(e,t)=>{let n=[],r=[],o=[];if(t.replace(A2,(s,a,c,l,u,b)=>{if(a)o.push(F0(a));else if(l){let f=o.join("");o=[],r.push(n.length===0?f:N0(e,n)(f)),n.push({inverse:c,styles:j2(l)})}else if(u){if(n.length===0)throw new Error("Found extraneous } in Chalk template literal");r.push(N0(e,n)(o.join(""))),o=[],n.pop()}else o.push(b)}),r.push(o.join("")),n.length>0){let s=`Chalk template literal is missing ${n.length} closing bracket${n.length===1?"":"s"} (\`}\`)`;throw new Error(s)}return r.join("")}});var n0=w((ae,U0)=>{"use strict";var j=R0(),{stdout:Z,stderr:Q}=B0(),{stringReplaceAll:I2,stringEncaseCRLFWithFirstIndex:F2}=j0(),Y0=["ansi","ansi","ansi256","ansi16m"],T=Object.create(null),N2=(e,t={})=>{if(t.level>3||t.level<0)throw new Error("The `level` option should be an integer from 0 to 3");let n=Z?Z.level:0;e.level=t.level===void 0?n:t.level},D0=class{constructor(t){return q0(t)}},q0=e=>{let t={};return N2(t,e),t.template=(...n)=>Y2(t.template,...n),Object.setPrototypeOf(t,H.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},t.template.Instance=D0,t.template};function H(e){return q0(e)}for(let[e,t]of Object.entries(j))T[e]={get(){let n=U(this,e0(t.open,t.close,this._styler),this._isEmpty);return Object.defineProperty(this,e,{value:n}),n}};T.visible={get(){let e=U(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:e}),e}};var H0=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(let e of H0)T[e]={get(){let{level:t}=this;return function(...n){let r=e0(j.color[Y0[t]][e](...n),j.color.close,this._styler);return U(this,r,this._isEmpty)}}};for(let e of H0){let t="bg"+e[0].toUpperCase()+e.slice(1);T[t]={get(){let{level:n}=this;return function(...r){let o=e0(j.bgColor[Y0[n]][e](...r),j.bgColor.close,this._styler);return U(this,o,this._isEmpty)}}}}var P2=Object.defineProperties(()=>{},d0(h0({},T),{level:{enumerable:!0,get(){return this._generator.level},set(e){this._generator.level=e}}})),e0=(e,t,n)=>{let r,o;return n===void 0?(r=e,o=t):(r=n.openAll+e,o=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:o,parent:n}},U=(e,t,n)=>{let r=(...o)=>$2(r,o.length===1?""+o[0]:o.join(" "));return r.__proto__=P2,r._generator=e,r._styler=t,r._isEmpty=n,r},$2=(e,t)=>{if(e.level<=0||!t)return e._isEmpty?"":t;let n=e._styler;if(n===void 0)return t;let{openAll:r,closeAll:o}=n;if(t.indexOf("")!==-1)for(;n!==void 0;)t=I2(t,n.close,n.open),n=n.parent;let s=t.indexOf(`
`);return s!==-1&&(t=F2(t,o,r,s)),r+t+o},t0,Y2=(e,...t)=>{let[n]=t;if(!Array.isArray(n))return t.join(" ");let r=t.slice(1),o=[n.raw[0]];for(let s=1;s<n.length;s++)o.push(String(r[s-1]).replace(/[{}\\]/g,"\\$&"),String(n.raw[s]));return t0===void 0&&(t0=$0()),t0(e,o.join(""))};Object.defineProperties(H.prototype,T);var I=H();I.supportsColor=Z;I.stderr=H({level:Q?Q.level:0});I.stderr.supportsColor=Q;I.Level={None:0,Basic:1,Ansi256:2,TrueColor:3,0:"None",1:"Basic",2:"Ansi256",3:"TrueColor"};U0.exports=I});var o2=B(require("fs")),O=B(n0());var V0=B(require("path")),V=[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,92821,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42416,83315,21168,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46752,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,23232,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19195,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448,84835,37744,18936,18800,25776,92326,59984,27424,108228,43744,37600,53987,51552,54615,54432,55888,23893,22176,42704,21972,21200,43448,43344,46240,46758,44368,21920,43940,42416,21168,45683,26928,29495,27296,44368,84821,19296,42352,21732,53600,59752,54560,55968,92838,22224,19168,43476,41680,53584,62034,54560],G0=["\u6B63","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D","\u4E03","\u516B","\u4E5D","\u5341","\u51AC","\u814A"],v={0:"\u521D",1:"\u4E00",2:"\u4E8C",3:"\u4E09",4:"\u56DB",5:"\u4E94",6:"\u516D",7:"\u4E03",8:"\u516B",9:"\u4E5D",10:"\u5341",20:"\u5EFF"},z0=["\u9F20","\u725B","\u864E","\u5154","\u9F99","\u86C7","\u9A6C","\u7F8A","\u7334","\u9E21","\u72D7","\u732A"],K0=["\u7532","\u4E59","\u4E19","\u4E01","\u620A","\u5DF1","\u5E9A","\u8F9B","\u58EC","\u7678"],W0=["\u5B50","\u4E11","\u5BC5","\u536F","\u8FB0","\u5DF3","\u5348","\u672A","\u7533","\u9149","\u620C","\u4EA5"],r0=["\u5C0F\u5BD2","\u5927\u5BD2","\u7ACB\u6625","\u96E8\u6C34","\u60CA\u86F0","\u6625\u5206","\u6E05\u660E","\u8C37\u96E8","\u7ACB\u590F","\u5C0F\u6EE1","\u8292\u79CD","\u590F\u81F3","\u5C0F\u6691","\u5927\u6691","\u7ACB\u79CB","\u5904\u6691","\u767D\u9732","\u79CB\u5206","\u5BD2\u9732","\u971C\u964D","\u7ACB\u51AC","\u5C0F\u96EA","\u5927\u96EA","\u51AC\u81F3"],X0=["062004190621052006210622072308230823092408230722","062104190621052106220622082308240824092408230822","062105190621062106220722082408240824092408230823","062105200722062107220722082409240924092408230823","072105200621052006210622072308230823092408230722","062104190621052106220622082308240824092408230822","062105190621062106220622082408240824092408230823","062105200722062107220722082409240924092408230823","072105200621052006210622072308230823092408230722","062104190621052106220622082308240824092408230822","062105190621062106220622082408240824092408230823","062105200722062107220722082409240924092408230823","072105200621052006210622072308230823092408220722","062004190621052106220622082308240823092408230822","062104190621052106220622082408240824092408230823","062105200622062106220722082408240924092408230823","062105200621052006210622072308230823082408220722","062004190621052106210622082308240823092408230822","062104190621052106220622082408240824092408230822","062105200622062106220722082408240924092408230823","062105200621052006210622072308230823082408220722","062004190621052006210622082308240823092408230722","062104190621052106220622082408240824092408230822","062105190621062106220722082408240924092408230823","062105200621052006210622072308230823082408220722","062004190621052006210622082308240823092408230722","0621041906210521062206220823082408240924
`),g("\u793A\u4F8B: "),g(" cal "+O.default.grey("# \u4E0D\u5E26\u53C2\u6570\u6253\u5370\u5F53\u524D\u5E74\u6708")),g(" cal -y "+O.default.grey("# -y \u4E0D\u63A5\u53C2\u6570, \u6253\u5370\u5F53\u524D\u5E74\u7684\u6240\u6709\u6708\u4EFD")),g(" cal -y 2000 "+O.default.grey("# \u6253\u5370\u6307\u5B9A\u5E74\u4EFD\u7684\u6240\u6709\u6708\u4EFD")),g(" cal -y 2021 5 "+O.default.grey("# \u6253\u5370\u6307\u5B9A\u5E74\u4EFD, \u6307\u5B9A\u6708\u4EFD")),g(" cal -y 2000 -m 3 "+O.default.grey("# \u540C\u4E0A")),g(" cal -m 5 "+O.default.grey("# \u6253\u5370\u5F53\u524D\u5E74\u4EFD\u7684 \u6307\u5B9A\u6708\u4EFD")),g(' cal -c {"2021.12.11":"\u73ED","2021.12.12":"\u4F11"} '+O.default.grey("# \u5BFC\u5165\u81EA\u5B9A\u4E49\u4F11\u5047\u65E5")),process.exit()}switch($){case"-y":switch(E.length){case 0:l0(y);break;case 1:case 2:y=+E.shift(),p=+E.shift(),y===y?p<13&&p>0?M(y,p-1):l0(y):console.log("-y \u53C2\u6570\u5F02\u5E38");break;case 3:$=E.shift(),p=+E.shift(),$==="-m"&&p<13&&p>0?M(y,p-1):console.log("-m \u53C2\u6570\u5F02\u5E38");break;default:console.log("-y \u53C2\u6570\u5F02\u5E38");break}break;case"-m":p=+E.shift(),p<13&&p>0?M(y,p-1):console.log("-m \u53C2\u6570\u5F02\u5E38");break;case"-v":g(s2);break;case"-h":W2();break;case"-c":let e=E.shift();if(e)try{JSON.parse(e),o2.default.writeFileSync(N,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:$?(y=+$,p=+E.shift(),y===y?p<13&&p>0?M(y,p-1):l0(y):console.log("\u53C2\u6570\u5F02\u5E38")):M(y,p);break}process.exit();