Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Neofetchライクな自己紹介ツールyuyufetchを作った / Created yuyu...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Hiroya-W
November 25, 2022
Technology
350
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Neofetchライクな自己紹介ツールyuyufetchを作った / Created yuyufetch, a Neofetch-like self-introduction tool
Hiroya-W
November 25, 2022
More Decks by Hiroya-W
See All by Hiroya-W
PSRにのっかってバックエンドサーバを書く / Write a backend server using PSR
hyuyukun
0
95
phina.jsで弾幕シューティングを作る / Creating a bullet-hell shooter with phina.js
hyuyukun
0
300
ピアノ経験ゼロからピアノを練習して弾いてみた / I practiced and played the piano from zero piano experience.
hyuyukun
1
160
Blenderに入門しました / I started to use Blender
hyuyukun
0
160
気軽にパソコンを吹き飛ばせるようにするために / To initialize your computer easily
hyuyukun
0
110
僕っぽいことを喋るBotをマストドンで育てています / I'm growing a bot on mastodon that talks like me.
hyuyukun
0
150
4年と半年かけてようやくフロントエンドを書けるようになった / It took me 4 years and 6 months to be able to write the frontend
hyuyukun
0
350
世界観を考察するのが好き?Sound Horizonはいいぞ / Introduction to Sound Horizon
hyuyukun
0
1.1k
夏インターンと趣味開発 / Summer Internships and Hobby Development
hyuyukun
0
110
Other Decks in Technology
See All in Technology
#エンジニアBooks 30分でわかる 「技術記事を書く技術」 / engineer-books 2026-06-30
jnchito
1
100
技術・能力を向上する原理原則 #きのこセッションa #きのこ2026
bash0c7
0
130
OTel × Datadog で 「AI活用」を計測し、改善に繋げる
shihochan
2
840
AI 不只幫你寫 Code: 當專案從 300 暴增到 1500, 我們如何撐住 DevOps
appleboy
0
250
5分でわかるDuckDB Quack
chanyou0311
4
250
AIチャット検索改善の3週間
kworkdev
PRO
2
190
FPGAの開発コンペでZephyrを使ってみた
iotengineer22
0
200
AIのReact習熟度を測る
uhyo
2
690
データレイクの「見えない問題」を可視化する
sansantech
PRO
1
200
アラート調査向けAIエージェントの本番導入とその後/AI Agents for Alert Investigation: Production Deployment and After
taddy_919
1
170
AIが自律的に回る開発ループを設計してチーム開発に組み込む
nekorush14
0
130
ぼっちではじめた登壇が「51名」「241件」の発信に化けた
subroh0508
1
320
Featured
See All Featured
Building Applications with DynamoDB
mza
96
7.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Technical Leadership for Architectural Decision Making
baasie
3
420
Done Done
chrislema
186
16k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
400
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
620
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
490
Utilizing Notion as your number one productivity tool
mfonobong
4
330
Become a Pro
speakerdeck
PRO
31
6k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
870
Transcript
/FPGFUDIϥΠΫͳ ࣗݾհπʔϧͷ ZVZVGFUDIΛ࡞ͬͨ ゆゆ君(@Hyuyu_kun) in あくあたん工房 2022/11/25
とつぜんですが 2
自己紹介どうやってますか 3
LTなら1枚スライドを挟めばいいですが 4
5
名刺を渡す 6
自分のホームページを見せる 7
僕は 8
バイナリを渡します 9
デモします 10
yuyufetch 11 n GitHub • https://github.com/Hiroya-W/yuyufetch n 使い方 • インストールして
• $ go install github.com/Hiroya- W/yuyufetch/cmd/yuyufetch@latest • 実行 • $ yuyufetch n きっかけ • Twitterでやっている人を見て作りたくなって作った
yuyufetch 12 n 好きポイント n Shell: Japanese n Uptime: 199244h1m0s
Neofetch 13 n システム情報を表示するツール n GitHub • https://github.com/dylanaraps/neofetch • 1つのBashスクリプトで書かれている
n パソコン何使っているん?って 聞かれたら、とりあえずこれ見て って言えばOK
(余談) NiTch 14 n 他にも同じようなツールはある (の1例) n GitHub • https://github.com/unxsh/nitch
• Nimを使って書かれている • Neofetch同様カスタマイズが可能
jp2a: JPEG/PNG to ASCII converter 15 n 画像をAAに変換するツール n GitHub
• https://github.com/Talinx/jp2a • JPEGだけじゃなくてPNGにも対応している
jp2aの使い方 n ソースビルドするかDockerを使う方法(Dockerが楽だと思う) • $ docker run -t --rm -e
COLORTERM="$COLORTERM" -v "$(pwd)":/app talinx/jp2a n オプション • --colors • 色付きで出力する。 • --size=WxH • 出力サイズ(幅は1文字が半角なのでW=2Hにするといい感じ)。 • --chars=… • AAに使う文字の組み合わせ。左側が黒に近い色、右側が白に近い色で使う。 • --background=dark, --background=light • 文字色の色味が変わる。背景色が暗いか明るいかで使い分けると良いと思う。 16
自動生成出来るようにしたいなと思ったり 17
自動生成出来るようにしたいなと思ったり 18 Neofetchはテキスト埋め込んでいるので別にいいかと思ったり
GoのCLIツールのリポジトリ構成(バイナリ配布) ! . ├── & bin │ └── , yuyufetch
├── 4 go.mod ├── 9 lib │ ├── ; informations.go # package yuyufetch │ ├── ; version.go # package yuyufetch │ └── ; yuyufetch.go # package yuyufetch ├── , LICENSE ├── ; main.go # package main ├── I Makefile └── K README.md 19
GoのCLIツールのリポジトリ構成(ライブラリ配布) ! . ├── & bin │ └── , yuyufetch
├── ! cmd │ └── ! yuyufetch │ └── 6 main.go # package main ├── = go.mod ├── 6 informations.go # package yuyufetch ├── , LICENSE ├── F Makefile ├── I README.md ├── 6 version.go # package yuyufetch └── 6 yuyufetch.go # package yuyufetch 20
CLI構造体で出力先と入力元を制御 21 // 定義 type CLI struct { Stdout io.Writer
Stderr io.Writer Stdin io.Reader } func (cli *CLI) Run(args []string) error { // something } // メインプログラムで使う時 cli := &mytool.CLI{ Stdout: os.Stdout, Stderr: os.Stderr, Stdin: os.Stdin, } fmt.Fprintln(cli.Stdout, ”Hello") // テストで使う時 s := “-input=hoge –output=fuga” input := “piyo” want := “correct” var got bytes.Buffer cli := &mytool.CLI{ // 置き換える Stdout: &got, Stderr: &got, Stdin: strings.NewReader(input), } args := strings.Split(s, " ") err := cli.Run(args) if got := got.String(); got != want { fmt.Printfln("want %q, but got %q", want, got) }
flagパッケージ: CLIのオプションを作る 22 var showVersion bool fs := flag.NewFlagSet(args[0], flag.ContinueOnError)
fs.BoolVar(&showVersion, "v", false, "show version") fs.BoolVar(&showVersion, "version", false, "show version") fs.Usage = func() { fmt.Printf("yuyufetch %s¥n¥n", version) fmt.Printf("Usage:¥n %s [Options]¥n¥n", "yuyufetch") fmt.Println("Options:") fs.PrintDefaults() fmt.Println("") } if err := fs.Parse(args[1:]); err != nil { return err } if showVersion { fmt.Fprintln(cli.Stdout, "yuyufetch", version) return nil }
ロゴの埋め込み 23 n jp2aの出力をそのままベタ書き… n エスケープシーケンスの扱い • ヒアドキュメント(``で囲む文字列)は、そのまま 表示される •
¥nや¥tは、改行やタブにならずそのまま • jp2aの出力をコピペした場合は、見えない文字で 挿入されている • エスケープコードを ¥x1b と書く場合は “” で 囲む文字列として書く
やりたいこと n このロゴを埋め込んでいるところをなんとかしたい • 自動生成したい n ターミナルサイズに応じてサイズ調整 • 文字列の折返しをしないようにして、ロゴが崩れないように n
色付け部分 • エスケープシーケンスをくっつけた文字列を生成する関数? 24
yuyufetchを作った話でした 25
ありがとうございました
参考文献 n みんなのGo言語 現場で使える実践テクニック n Hiroya-W/yuyufetch • https://github.com/Hiroya-W/yuyufetch n Goで書くテスタブルなCLIツールの作り方
• https://gihyo.jp/article/2022/11/tsukinami-go-03 27