bash-calendar/index.js

9 lines
30 KiB
JavaScript
Raw Normal View History

2021-11-26 17:24:37 +08:00
#!/usr/bin/env node
2021-11-30 18:55:38 +08:00
var Xe=Object.create;var L=Object.defineProperty,Ze=Object.defineProperties,Je=Object.getOwnPropertyDescriptor,Qe=Object.getOwnPropertyDescriptors,e0=Object.getOwnPropertyNames,te=Object.getOwnPropertySymbols,t0=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,n0=Object.prototype.propertyIsEnumerable;var re=(e,t,n)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,oe=(e,t)=>{for(var n in t||(t={}))ne.call(t,n)&&re(e,n,t[n]);if(te)for(var n of te(t))n0.call(t,n)&&re(e,n,t[n]);return e},se=(e,t)=>Ze(e,Qe(t)),r0=e=>L(e,"__esModule",{value:!0});var v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var o0=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of e0(t))!ne.call(e,r)&&r!=="default"&&L(e,r,{get:()=>t[r],enumerable:!(n=Je(t,r))||n.enumerable});return e},ae=e=>o0(r0(L(e!=null?Xe(t0(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var ce=v(($0,le)=>{"use strict";le.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:[11
2021-11-30 18:50:37 +08:00
`:`
`)+n,o=r+1,r=e.indexOf(`
2021-11-30 18:55:38 +08:00
`,o)}while(r!==-1);return s+=e.substr(o),s};Oe.exports={stringReplaceAll:p0,stringEncaseCRLFWithFirstIndex:y0}});var Te=v((K0,Be)=>{"use strict";var m0=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,Ae=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,v0=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,k0=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,w0=new Map([["n",`
`],["r","\r"],["t"," "],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e",""],["a","\x07"]]);function _e(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)):w0.get(e)||e}function C0(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(v0))n.push(o[2].replace(k0,(c,l,u)=>l?_e(l):u));else throw new Error(`Invalid Chalk template style argument: ${s} (in style '${e}')`)}return n}function E0(e){Ae.lastIndex=0;let t=[],n;for(;(n=Ae.exec(e))!==null;){let r=n[1];if(n[2]){let o=C0(r,n[2]);t.push([r].concat(o))}else t.push([r])}return t}function Se(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}Be.exports=(e,t)=>{let n=[],r=[],o=[];if(t.replace(m0,(s,a,c,l,u,h)=>{if(a)o.push(_e(a));else if(l){let b=o.join("");o=[],r.push(n.length===0?b:Se(e,n)(b)),n.push({inverse:c,styles:E0(l)})}else if(u){if(n.length===0)throw new Error("Found extraneous } in Chalk template literal");r.push(Se(e,n)(o.join(""))),o=[],n.pop()}else o.push(h)}),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 X=v((X0,Fe)=>{"use strict";var S=ve(),{stdout:H,stderr:z}=Me(),{stringReplaceAll:M0,stringEncaseCRLFWithFirstIndex:O0}=Re(),je=["ansi","ansi","ansi256","ansi16m"],A=Object.create(null),R0=(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=H?H.level:0;e.level=t.level===void 0?n:t.level},Le=class{constructor(t){return Ie(t)}},Ie=e=>{let t={};return R0(t,e),t.template=(...n)=>S0(t.template,...n),Object.setPrototypeOf(t,F.prototype),Object.setPrototypeOf(t.template,t),t.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},t.template.Instance=Le,t.template};function F(e){return Ie(e)}for(let[e,t]of Object.entries(S))A[e]={get(){let n=P(this,W(t.open,t.close,this._styler),this._isEmpty);return Object.defineProperty(this,e,{value:n}),n}};A.visible={get(){let e=P(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:e}),e}};var Ne=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(let e of Ne)A[e]={get(){let{level:t}=this;return function(...n){let r=W(S.color[je[t]][e](...n),S.color.close,this._styler);return P(this,r,this._isEmpty)}}};for(let e of Ne){let t="bg"+e[0].toUpperCase()+e.slice(1);A[t]={get(){let{level:n}=this;return function(...r){let o=W(S.bgColor[je[n]][e](...r),S.bgColor.close,this._styler);return P(this,o,this._isEmpty)}}}}var A0=Object.defineProperties(()=>{},se(oe({},A),{level:{enumerable:!0,get(){return this._generator.level},set(e){this._generator.level=e}}})),W=(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}},P=(e,t,n)=>{let r=(...o)=>_0(r,o.length===1?""+o[0]:o.join(" "));return r.__proto__=A0,r._generator=e,r._styler=t,r._isEmpty=n,r},_0=(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=M0(t,n.close,n.open),n=n.parent;let s=t.indexOf(`
`);return s!==-1&&(t=O0(t,o,r,s)),r+t+o},K,S0=(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 K===void 0&&(K=Te()),K(e,o.join(""))};Object.defineProperties(F.prototype,A);var B=F();B.supportsColor=H;B.stderr=F({level:z?z.level:0});B.stderr.supportsColor=z;B.Level={None:0,Basic:1,Ansi256:2,TrueColor:3,0:"None",1:"Basic",2:"Ansi256",3:"TrueColor"};Fe.exports=B});var E=ae(X());var f=ae(X());var D=[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],Pe=["\u6B63","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D","\u4E03","\u516B","\u4E5D","\u5341","\u51AC","\u814A"],m={0:"\u521D",1:"\u4E00",2:"\u4E8C",3:"\u4E09",4:"\u56DB",5:"\u4E94",6:"\u516D",7:"\u4E03",8:"\u516B",9:"\u4E5D",10:"\u5341",20:"\u5EFF"},De=["\u9F20","\u725B","\u864E","\u5154","\u9F99","\u86C7","\u9A6C","\u7F8A","\u7334","\u9E21","\u72D7","\u732A"],Ye=["\u7532","\u4E59","\u4E19","\u4E01","\u620A","\u5DF1","\u5E9A","\u8F9B","\u58EC","\u7678"],$e=["\u5B50","\u4E11","\u5BC5","\u536F","\u8FB0","\u5DF3","\u5348","\u672A","\u7533","\u9149","\u620C","\u4EA5"];var Z={"1.1":"\u6625\u8282","1.15":"\u5143\u5BB5\u8282","2.2":"\u9F99\u62AC\u5934","3.3":"\u4E0A\u5DF3\u8282","5.5":"\u7AEF\u5348\u8282","7.7":"\u4E03\u5915\u8282","7.15":"\u4E2D\u5143\u8282","8.15":"\u4E2D\u79CB\u8282","9.9":"\u91CD\u9633\u8282","10.1":"\u5BD2\u8863\u8282","10.15":"\u4E0B\u5143\u8282","12.8":"\u814A\u516B\u8282","12.23":"\u5317\u65B9\u5C0F\u5E74","12.24":"\u5357\u65B9\u5C0F\u5E74","12.30":"\u9664\u5915"},qe={"1.1":"\u5143\u65E6\u8282","2.14":"\u60C5\u4EBA\u8282","3.8":"\u5987\u5973\u8282","3.12":"\u690D\u6811\u8282","4.1":"\u611A\u4EBA\u8282","5.1":"\u52B3\u52A8\u8282","5.4":"\u9752\u5E74\u8282","5.12":"\u62A4\u58EB\u8282","6.1":"\u513F\u7AE5\u8282","7.1":"\u5EFA\u515A\u8282","8.1":"\u5EFA\u519B\u8282","9.10":"\u6559\u5E08\u8282","10.1":"\u56FD\u5E86\u8282","12.24":"\u5E73\u5B89\u591C","12.25":"\u5723\u8BDE\u8282"};function Y(e=1901,t=0,n=1){var r=Date.UTC(1900,0,31),o=Date.UTC(e,t,n),s=(o-r)/(24*60*60*1e3)+1,a,c,l={short:""};if(e<1901||e>2100)return l;for(let u=1900;u<=2100;u++){let h=B0(u);if(s-=h,s<=0){l.year=u,s+=h;break}}a=Ge(l.year),c=J(l.year);for(let u=0;u<a.length;u++)if(s-=a[u],s<=0){l.month=u,l.day=s+a[u],c>0&&u>=c&&(l.leap=u===c,l.month-=1);break}return l.festival=qe[`${t+1}.${n}`],l.leap||(l.month===11&&l.day===a.pop()?l.festival=Z["12.30"]:l.festival=Z[`${l.month+1}.${l.day}`]||l.festival),l.yearCN=Q(l.year),l.monthCN=(l.leap>0?"\u95F0":"")+Pe[l.month]+"\u6708",l.day<11?l.dayCN=m[0]+m[l.day]:l.day<20?l.dayCN=m[10]+m[l.day-10]:l.day===20?l.dayCN=m[2]+m[10]:l.day<30?l.dayCN=m[20]+m[l.day-20]:l.day===30&&(l.dayCN=m[3]+m[10]),l.short=l.festival?l.festival:l.day===1?l.monthCN:l.dayCN,l}function B0(e){var t=Ge(e);return t.reduce((n,r)=>n+=r,0)}function J(e){var t=D[e-1900];return t&15}function T0(e){var t=D[e-190
`),x("\u793A\u4F8B: "),x(" cal "+E.default.grey("# \u4E0D\u5E26\u53C2\u6570\u6253\u5370\u5F53\u524D\u5E74\u6708")),x(" cal -y "+E.default.grey("# -y \u4E0D\u63A5\u53C2\u6570, \u6253\u5370\u5F53\u524D\u5E74\u7684\u6240\u6709\u6708\u4EFD")),x(" cal -y 2000 "+E.default.grey("# \u6253\u5370\u6307\u5B9A\u5E74\u4EFD\u7684\u6240\u6709\u6708\u4EFD")),x(" cal -y 2021 5 "+E.default.grey("# \u6253\u5370\u6307\u5B9A\u5E74\u4EFD, \u6307\u5B9A\u6708\u4EFD")),x(" cal -y 2000 -m 3 "+E.default.grey("# \u540C\u4E0A")),x(" cal -m 5 "+E.default.grey("# \u6253\u5370\u5F53\u524D\u5E74\u4EFD\u7684 \u6307\u5B9A\u6708\u4EFD")),process.exit()}switch(j){case"-y":switch(w.length){case 0:ee(p);break;case 1:case 2:p=+w.shift(),g=+w.shift(),p===p?g<13&&g>0?C(p,g-1):ee(p):console.log("-y \u53C2\u6570\u5F02\u5E38");break;case 3:j=w.shift(),g=+w.shift(),j==="-m"&&g<13&&g>0?C(p,g-1):console.log("-m \u53C2\u6570\u5F02\u5E38");break;default:console.log("-y \u53C2\u6570\u5F02\u5E38");break}break;case"-m":g=+w.shift(),g<13&&g>0?C(p,g-1):console.log("-m \u53C2\u6570\u5F02\u5E38");break;case"-v":x(We);break;case"-h":D0();break;default:j?(p=+j,g=+w.shift(),p===p?g<13&&g>0?C(p,g-1):ee(p):console.log("\u53C2\u6570\u5F02\u5E38")):C(p,g);break}process.exit();