Files
hakorune/apps/ny-echo/main.nyash
Moe Charm de99b40bee Phase 12 TypeBox統合ABI設計完了: C ABI + Nyash ABI革命的統合
主な成果:
- TypeBox(型情報をBoxとして扱う)による統合ABI設計
- C ABI + Nyash ABIの完全統合仕様書作成
- 3大AI専門家(Gemini/Codex/ChatGPT5)による検証済み
- ChatGPT5の10個の安全性改善提案を反映
- README.mdのドキュメント更新(全起点から到達可能)

MapBox拡張:
- string型キーサポート(従来のi64に加えて)
- remove/clear/getOr/keysStr/valuesStr/toJson実装
- keys()/values()のランタイムシムサポート(TypeBox待ち)

その他の改善:
- Phase 11.9(文法統一化)ドキュメント追加
- Phase 16(FoldLang)ドキュメント追加
- 非同期タイムアウトテスト追加
- 各種ビルド警告(未使用import等)は次のリファクタリングで対応予定

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-02 09:26:09 +09:00

83 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ny-echo - 最小CLI実装
// 目的: I/O・StringBoxの道通し確認
// 使用法: ny-echo [--upper|--lower]
static box Main {
init { console, options }
main(args) {
me.console = new ConsoleBox()
me.options = me.parseArgs(args)
// バージョン表示グローバルNYASH_VERSION依存を避ける
if me.options.get("version") {
local ver = "1.0.0"
me.console.log("ny-echo v" + ver)
return 0
}
// ヘルプ表示
if me.options.get("help") {
me.showHelp()
return 0
}
// メインループ
me.processInput()
return 0
}
parseArgs(args) {
local options = new MapBox()
// foreach は未対応のため、index で明示ループ
local i = 0
local n = args.length()
loop(i < n) {
local arg = args.get(i)
if arg == "--upper" {
options.set("upper", true)
} else if arg == "--lower" {
options.set("lower", true)
} else if arg == "--version" || arg == "-v" {
options.set("version", true)
} else if arg == "--help" || arg == "-h" {
options.set("help", true)
}
i = i + 1
}
return options
}
processInput() {
loop(true) {
local input = me.console.readLine()
if input == null { return 0 } // EOF → 関数終了に変更break未対応MIR対策
local output = me.transformText(input)
me.console.log(output)
}
}
transformText(text) {
if me.options.get("upper") {
return text.toUpperCase()
} else if me.options.get("lower") {
return text.toLowerCase()
} else {
return text // そのまま出力
}
}
showHelp() {
me.console.log("Usage: ny-echo [OPTIONS]")
me.console.log("")
me.console.log("Options:")
me.console.log(" --upper Convert input to uppercase")
me.console.log(" --lower Convert input to lowercase")
me.console.log(" -v, --version Show version information")
me.console.log(" -h, --help Show this help message")
me.console.log("")
me.console.log("Reads from stdin and echoes to stdout with optional transformation.")
}
}