@@ -49,10 +49,9 @@ const widgets = NS.api.widgets;
4949const { pathToNode} = fsapi ;
5050const { E_SUC , E_ERR } = SHELL_ERROR_CODES ;
5151//const {Com, ErrCom, make_error_com} = comClasses;
52- const { Com } = ShellMod . comClasses ;
52+ const { SimpleCommand } = ShellMod . comClasses ;
5353const { Desk} = LOTW ;
5454const { make_icon_if_new} = Desk ;
55- const ADMIN_COM = class extends Com { run ( ) { this . no ( "must be in 'admin mode'!" ) ; } } ;
5655//»
5756
5857//Var«
@@ -112,7 +111,7 @@ const get_file_lines_from_args = async(args, term, errcb)=>{//«
112111//»
113112
114113//Commands«
115-
114+ const Com = SimpleCommand ;
116115/*«
117116const com_ = class extends Com{
118117async init(){
@@ -122,6 +121,8 @@ async run(){
122121}
123122»*/
124123
124+ const ADMIN_COM = class extends Com { run ( ) { this . no ( "must be in 'admin mode'!" ) ; } } ;
125+
125126const com_brep = class extends Com { //«
126127/*«
127128
@@ -245,7 +246,7 @@ this.doBrep();
245246//this.no();
246247}
247248/*
248- pipeIn(val){//«
249+ pipeIn(val){//Commented out «
249250 if (this.noStdin) return;
250251 if (isEOF(val)){
251252 this.doBrep();
@@ -501,79 +502,32 @@ cancel(){//«
501502} //»
502503
503504} //»
504-
505505const com_cat = class extends Com { //«
506-
507- /*«The algorithm for LOTW's 'cat'
508-
509- init:
510- 1) Check for no means of input and exit
511- 2) Block any piped input if either is true:
512- a) this.args.length > 0
513- b) this.stdin exists
514-
515- run:
516- 1) if no args:
517- a) send any standard input to the output steam and exit
518- b) listen for piped input until EOF and exit
519- 2) loop around all args, sending out anything that isn't an Error
520- 3) exit with this.nok() (calls this.ok() if this.numErrors===0, else calls this.no())
521-
522- Notes for this.nextArgAsText():
523- - this.numErrors is updated internally (in case the arg doesn't resolve to a file system node, etc.)
524- - It isn't an error for there *not* to be a next arg (null is returned when this.args is empty)
525-
526- »*/
527-
528- // #useTerm = false;
529- init ( ) { //«
530- if ( this . noInputOrArgs ( { noErr : true } ) ) {
531- this . useTerm = true ;
532- }
533- this . maybeSetNoPipe ( ) ;
534- } //»
535- async run ( ) { //«
536- if ( this . useTerm ) return this . doTermLoop ( ) ;
537- const { stdin} = this ;
538- if ( ! this . args . length ) {
539- if ( isStr ( stdin ) ) {
540- this . out ( stdin ) ;
541- this . ok ( ) ;
506+ async run ( ) { //«
507+ if ( this . args . length ) {
508+ let txt ;
509+ while ( txt = await this . nextArgAsText ( ) ) {
510+ if ( ! isErr ( txt ) ) this . out ( txt . join ( "\n" ) ) ;
542511 }
543- //else: we have piped input, and are waiting for an 'EOF' to exit
512+ this . nok ( ) ;
544513 return ;
545514 }
546- let txt ;
547- while ( txt = await this . nextArgAsText ( ) ) {
548- if ( ! isErr ( txt ) ) this . out ( txt . join ( "\n" ) ) ;
549- }
550- this . nok ( ) ;
551- } //»
552- pipeIn ( val ) { this . out ( val ) ; }
553- pipeDone ( ) { this . ok ( ) ; }
554- async doTermLoop ( ) { //«
555- while ( true ) {
556- let ln = await this . readLine ( ) ;
557- if ( isEOF ( ln ) ) {
558- this . ok ( ) ;
559- return ;
560- }
561- this . out ( ln ) ;
562- }
563- } //»
564-
565- /*
566- cancel(){//«
567- this.ok();
568- }//»
569- */
570-
515+ let rv ;
516+ while ( true ) {
517+ rv = await this . readStdinChunk ( ) ;
518+ if ( isEOF ( rv ) ) {
519+ return this . ok ( ) ;
520+ }
521+ this . out ( rv ) ;
522+ }
523+ } //»
571524} ; //»
525+
572526const com_grep = class extends Com { //«
573527//#re;
574528
575529async init ( ) { //«
576-
530+ return this . no ( "UPDATEMEPLEASE!!!" ) ;
577531 let patstr = this . args . shift ( ) ;
578532 if ( ! patstr ) {
579533 this . no ( "no pattern given" ) ;
@@ -962,6 +916,7 @@ async run(){
962916const com_wc = class extends Com { //«
963917//#noPipe;
964918async init ( ) {
919+ return this . no ( "UPDATEMEPLEASE!!!" ) ;
965920 if ( ! this . args . length && ! this . pipeFrom && ! this . stdin ) this . no ( "no args, no stdin, and not in a pipeline" ) ;
966921// if (!this.args.length && !this.pipeFrom) return this.no("no file args and not in a pipeline!");
967922 if ( this . args . length || this . stdin ) {
@@ -1093,7 +1048,7 @@ pipeDone(lines){
10931048 this . doDL ( ) ;
10941049}
10951050/*«
1096- pipeIn(val){
1051+ pipeIn(val){//Commented out
10971052 if (this.noPipe) return;
10981053 if (isEOF(val)){
10991054 this.out(val);
0 commit comments