-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from spiegel-im-spiegel/refactoring-by-golangc…
…i-lint Refactoring by golangci lint
- Loading branch information
Showing
17 changed files
with
303 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,28 @@ | |
[![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/spiegel-im-spiegel/mklink/master/LICENSE) | ||
[![GitHub release](http://img.shields.io/github/release/spiegel-im-spiegel/mklink.svg)](https://github.com/spiegel-im-spiegel/mklink/releases/latest) | ||
|
||
## Install | ||
## Declare [gpgpdump] module | ||
|
||
See [go.mod](https://github.com/spiegel-im-spiegel/mklink/blob/master/go.mod) file. | ||
|
||
### Module Requirement Graph | ||
|
||
``` | ||
$ export GO111MODULE=on | ||
$ go get github.com/spiegel-im-spiegel/mklink@latest | ||
$ go mod graph | ||
github.com/spiegel-im-spiegel/mklink github.com/PuerkitoBio/[email protected] | ||
github.com/spiegel-im-spiegel/mklink github.com/atotto/[email protected] | ||
github.com/spiegel-im-spiegel/mklink github.com/inconshreveable/[email protected] | ||
github.com/spiegel-im-spiegel/mklink github.com/mattn/[email protected] | ||
github.com/spiegel-im-spiegel/mklink github.com/pkg/[email protected] | ||
github.com/spiegel-im-spiegel/mklink github.com/spf13/[email protected] | ||
github.com/spiegel-im-spiegel/mklink github.com/spf13/[email protected] | ||
github.com/spiegel-im-spiegel/mklink github.com/spiegel-im-spiegel/[email protected] | ||
github.com/spiegel-im-spiegel/mklink golang.org/x/[email protected] | ||
github.com/spiegel-im-spiegel/mklink golang.org/x/[email protected] | ||
github.com/spiegel-im-spiegel/[email protected] github.com/mattn/[email protected] | ||
github.com/PuerkitoBio/[email protected] github.com/andybalholm/[email protected] | ||
github.com/PuerkitoBio/[email protected] golang.org/x/[email protected] | ||
github.com/andybalholm/[email protected] golang.org/x/[email protected] | ||
``` | ||
|
||
## Usage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package facade | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/atotto/clipboard" | ||
"github.com/pkg/errors" | ||
"github.com/spiegel-im-spiegel/gocli/prompt" | ||
"github.com/spiegel-im-spiegel/gocli/rwi" | ||
"github.com/spiegel-im-spiegel/mklink/cli/mklink/makelink" | ||
) | ||
|
||
func interactiveMode(ui *rwi.RWI, cxt *makelink.Context) error { | ||
p := prompt.New( | ||
rwi.New( | ||
rwi.WithReader(ui.Reader()), | ||
rwi.WithWriter(ui.Writer()), | ||
), | ||
func(url string) (string, error) { | ||
if url == "q" || url == "quit" { | ||
return "", prompt.ErrTerminate | ||
} | ||
r, err := cxt.MakeLink(url) | ||
if err != nil { | ||
return err.Error(), nil | ||
} | ||
buf := &bytes.Buffer{} | ||
if _, err := io.Copy(buf, r); err != nil { | ||
return "", err | ||
} | ||
fmt.Fprintln(buf) | ||
res := buf.String() | ||
return res, clipboard.WriteAll(res) | ||
}, | ||
prompt.WithPromptString("mklink> "), | ||
prompt.WithHeaderMessage("Input 'q' or 'quit' to stop"), | ||
) | ||
if !p.IsTerminal() { | ||
return errors.New("not terminal (or pipe?)") | ||
} | ||
if err := p.Run(); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
/* Copyright 2019 Spiegel | ||
* | ||
* 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. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.