-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix json to php class logic error
- Loading branch information
Showing
8 changed files
with
150 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* This file is part of Kite. | ||
* | ||
* @link https://github.com/inhere | ||
* @author https://github.com/inhere | ||
* @license MIT | ||
*/ | ||
|
||
namespace Inhere\Kite\Console\Controller; | ||
|
||
use Inhere\Console\Controller; | ||
use Inhere\Console\IO\Output; | ||
use Inhere\Kite\Console\Component\ContentsAutoReader; | ||
use Toolkit\PFlag\FlagsParser; | ||
use Toolkit\Stdlib\Str\UrlHelper; | ||
|
||
/** | ||
* Class HttpController | ||
*/ | ||
class HttpController extends Controller | ||
{ | ||
protected static string $name = 'http'; | ||
|
||
protected static string $desc = 'Some useful http tool commands'; | ||
|
||
/** | ||
* @return array{string: list<string>} | ||
*/ | ||
protected static function commandAliases(): array | ||
{ | ||
return [ | ||
'bulk2query' => ['2query', 'to-query'], | ||
]; | ||
} | ||
|
||
/** | ||
* convert k-v map text to http url query string. | ||
* | ||
* @options | ||
* -s,--source string;The source k-v map text. allow: FILEPATH, @clipboard;true | ||
* --not-enc,--not-encode bool;Not apply url-encode for generated string | ||
* | ||
* @param FlagsParser $fs | ||
* @param Output $output | ||
*/ | ||
public function bulk2queryCommand(FlagsParser $fs, Output $output): void | ||
{ | ||
$source = $fs->getOpt('source'); | ||
$source = ContentsAutoReader::readFrom($source); | ||
|
||
$output->colored('SOURCE:'); | ||
$output->writeRaw($source); | ||
|
||
$query = str_replace([': ', "\n", ':'], ['=', '&', '='], $source); | ||
if (!$fs->getOpt('not-encode')) { | ||
$query = UrlHelper::encode($query); | ||
} | ||
|
||
$output->colored('RESULT:'); | ||
$output->writeRaw($query); | ||
} | ||
} |
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
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,29 @@ | ||
#!/usr/bin/env bash | ||
# install go on linux | ||
|
||
GO_VER=1.17.6 | ||
GO_TAR=go$GO_VER.linux-amd64.tar.gz | ||
echo "Will install the $GO_TAR" | ||
|
||
cd /tmp || exit 2 | ||
# mac https://studygolang.com/dl/golang/go1.17.6.darwin-amd64.pkg | ||
# linux https://studygolang.com/dl/golang/go1.17.6.linux-amd64.tar.gz | ||
wget https://studygolang.com/dl/golang/$GO_TAR | ||
|
||
# decompress | ||
tar -C /usr/local -xzf $GO_TAR | ||
|
||
cat <<EOF | ||
The go $GO_VER download ok and decompress to /usr/local/go. | ||
please config something for enable it. | ||
# config: | ||
# .bashrc OR /etc/profile 最后一行添加 | ||
export PATH=\$PATH:/usr/local/go/bin | ||
# check install | ||
go version | ||
# go env -w GOPROXY=https://goproxy.io,direct | ||
go env -w GOPROXY=https://goproxy.cn,direct | ||
go env | ||
EOF |