Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions cli/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bufio"
"bytes"
"context"
"crypto/ed25519"
Expand All @@ -10,6 +11,19 @@ import (
"errors"
"flag"
"fmt"
"math/big"
"math/bits"
"net"
"net/http"
"net/netip"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"

"github.com/mattn/go-isatty"
"github.com/pterm/pterm"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
Expand All @@ -32,17 +46,6 @@ import (
"github.com/xssnick/tonutils-storage/db"
"github.com/xssnick/tonutils-storage/provider"
"github.com/xssnick/tonutils-storage/storage"
"math/big"
"math/bits"
"net"
"net/http"
"net/netip"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"

_ "net/http/pprof"
)
Expand Down Expand Up @@ -376,7 +379,16 @@ func main() {
list()

for {
cmd, err := pterm.DefaultInteractiveTextInput.WithOnInterruptFunc(onStop).Show("Command")
var cmd string
var err error
if !isatty.IsTerminal(os.Stdout.Fd()) {
in := bufio.NewReader(os.Stdin)
cmd, err = in.ReadString('\n')
cmd = strings.TrimSpace(cmd)
} else {
cmd, err = pterm.DefaultInteractiveTextInput.WithOnInterruptFunc(onStop).Show("Command")
}

if err != nil {
pterm.Warning.Println("unexpected input:" + err.Error())
continue
Expand Down