// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
packagecli
import(
"fmt"
"log"
"os"
"path/filepath"
"time"
C"github.com/urfave/cli/v2"
)
funcgenerateReaderFrom(f,fg*os.File,iint){
// non generic version
fmt.Fprintf(f,"\n// From%d converts a function with %d parameters returning a [R] into a function with %d parameters returning a [Reader[C, R]]\n// The first parameter is considered to be the context [C] of the reader\n",i,i+1,i)
fmt.Fprintf(fg,"\n// From%d converts a function with %d parameters returning a [R] into a function with %d parameters returning a [GRA]\n// The first parameter is considered to be the context [C].\n",i,i+1,i)
fmt.Fprintf(fg,"func From%d[GRA ~func(C) R, F ~func(C",i)
forj:=0;j<i;j++{
fmt.Fprintf(fg,", T%d",j)
}
fmt.Fprintf(fg,") R")
forj:=0;j<i;j++{
fmt.Fprintf(fg,", T%d",j)
}
fmt.Fprintf(fg,", C, R any](f F) func(")
forj:=0;j<i;j++{
ifj>0{
fmt.Fprintf(fg,", ")
}
fmt.Fprintf(fg,"T%d",j)
}
fmt.Fprintf(fg,") GRA {\n")
fmt.Fprintf(fg," return func(")
forj:=0;j<i;j++{
ifj>0{
fmt.Fprintf(fg,", ")
}
fmt.Fprintf(fg,"t%d T%d",j,j)
}
fmt.Fprintf(fg,") GRA {\n")
fmt.Fprintf(fg," return MakeReader[GRA](func(r C) R {\n")