Giter Club home page Giter Club logo

Comments (10)

coolaj86 avatar coolaj86 commented on May 22, 2024 1

Update

Simple Fix: Use proper, system-specific file descriptors. See #28.

from curlie.

bitcrazed avatar bitcrazed commented on May 22, 2024 1

Glad to have helped. If you're interested in the history and internals of Console & Windows' command-line, please read through this 5-part blog series. In this series, you'll find, for example, that like Bash, Cmd and PowerShell are simply command-line shells, but that Windows "helps" by creating and attaching a Console instance to them, providing the (now somewhat dated) UI through which you interact with the shells.

Also, note that Console is now largely in maintenance - it'll likely be shipped in Windows for years to come, and may pick up a few improvements here and there, but all new development & new features are being poured into Windows Terminal which I STRONGLY encourage you to use if possible, if you're not already.

from curlie.

rs avatar rs commented on May 22, 2024

Just pushed a new release, please try the 1.3.0 and tell me if it's better.

from curlie.

johnmhm avatar johnmhm commented on May 22, 2024

Issue persists unfortunately. Here's the output of -V if that helps:

C:\Users\johnmhm>curlie -V
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: [unreleased]
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL

It hangs after the last line, and needs ctrl-c to return to a command line.

from curlie.

coolaj86 avatar coolaj86 commented on May 22, 2024

I'm noticing the same thing. I'm on a recent Windows 10 release on a Virtual Machine (virtualbox).

The built-in curl.exe is working without a problem.

from curlie.

coolaj86 avatar coolaj86 commented on May 22, 2024

If we remove x/crypto/ssh/terminal and just assume a terminal, it works as expected.

This is possibly a bug that should be filed with that package against Windows.

diff --git a/main.go b/main.go
index c3746cf..9f62d13 100644
--- a/main.go
+++ b/main.go
@@ -12,7 +12,6 @@ import (

        "github.com/rs/curlie/args"
        "github.com/rs/curlie/formatter"
-       "golang.org/x/crypto/ssh/terminal"
 )

 func main() {
@@ -52,7 +51,7 @@ func main() {
                stdout = &formatter.HelpAdapter{Out: stdout, CmdName: os.Args[0]}
        } else {
                isForm := opts.Has("F")
-               if pretty || terminal.IsTerminal(1) {
+               if pretty || true /*|| terminal.IsTerminal(1)*/ {
                        inputWriter = &formatter.JSON{
                        stdout = &formatter.BinaryFilter{Out: stdout}
                }
-               if pretty || terminal.IsTerminal(2) {
+               if pretty || true /*|| terminal.IsTerminal(2) */ {
                        // If stderr is not redirected, output headers.
                        if !quiet {
                                opts = append(opts, "-v")
@@ -80,7 +79,7 @@ func main() {
                        // If data is provided via -d, read it from there for the verbose mode.
                        // XXX handle the @filename case.
                        inputWriter.Write([]byte(data))
-               } else if !terminal.IsTerminal(0) {
+               } else if false /*!terminal.IsTerminal(0)*/ {
                        // If something is piped in to the command, tell curl to use it as input.
                        opts = append(opts, "-d@-")
                        // Tee the stdin to the buffer used show the posted data in verbose mode.
@@ -118,7 +117,7 @@ func main() {
                Verbose: verbose,
                Post:    input,
        }
-       if (opts.Has("I") || opts.Has("head")) && terminal.IsTerminal(1) {
+       if (opts.Has("I") || opts.Has("head")) && true /* terminal.IsTerminal(1) */ {
                cmd.Stdout = ioutil.Discard
        }
        status := 0

I'd like to propose creating a dummy check for when compiling for Windows. I'd be happy to submit that PR.

Thoughts @rs?

from curlie.

rs avatar rs commented on May 22, 2024

Ok

from curlie.

coolaj86 avatar coolaj86 commented on May 22, 2024

My conclusion from testing is that it is not possible to detect the Terminal properly on Windows 10 through the x/crypto/ssh/terminal package.

curlie when treating cmd.exe as a Terminal, curlie will output some extra junk.

Windows Terminal, unfortunately, is not detected as a proper console, despite behaving as one.

cc/ @jkunkee Re: Windows Terminal: Do you know anyone that could help with this?

from curlie.

bitcrazed avatar bitcrazed commented on May 22, 2024

Hi. One of Microsoft's Terminal/Console PMs here.

Windows' (legacy) Console has supported a pretty decent range of VT sequences since 2017. The new Windows Terminal much more comprehensive support for VT, and is updated ~monthly.

If Curlie doesn't enable VT mode, and/or emits VT sequences or Unicode glyphs that Console doesn't support, you may see some garbage and/or Unicode placeholder symbols (�).

Curlie should enable Console's VT Processing mode when starting up by grabbing the handle for STDOUT, and calling SetConsoleMode() to ENABLE_VIRTUAL_TERMINAL_PROCESSING. Here's how Curl does it.

If you want to emit Unicode glyphs, you'll need to use the wide char output variants. Again, here's how Curl does it.

FWIW, I am knocking together a small command-line tool ("Paws") that supports VT for colorized output (if available), and monochrome if not.

HTH.

from curlie.

coolaj86 avatar coolaj86 commented on May 22, 2024

Thanks @bitcrazed! That cleared up some of my misconceptions.

I'm glad to hear that Console (default cmd.exe) supports colors after all.

Opening up a new issue #29 to deal specifically with the color issue now that we've got the basic Stdout problem solved that was the root of this original issue.

from curlie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.