忘记国旗和脚本:只需重命名文件。
Forget Flags and Scripts: Just Rename the File

原始链接: https://robertsdotpm.github.io/software_engineering/program_names_as_input.html

这个概念提出了一种新颖的程序配置方法:将所有必要信息直接嵌入到文件名中。程序不再依赖于容易丢失或特定于环境的标志或脚本,而是*读取*自身的文件名来确定其行为。 这创造了自包含、可立即共享的执行文件。例如,安装程序可以根据文件名中的模块名称进行调整,人工智能实验运行器可以根据名称中的参数进行配置,简单的实用程序可以由文件名关键词触发。甚至可以通过运行重命名的文件来启动复杂的设置,如P2P VPN隧道。 核心思想是通过将文件名作为程序的接口来消除设置和配置的麻烦,从而实现可移植性、可重复性和易于共享,只需一个重命名的文件即可。它挑战了传统方法,并为各种应用程序提供了简化的体验。

一个 Hacker News 的讨论围绕着一种新的命令行参数方法:将可执行文件本身重命名以编码标志。这个想法,发表在 [robertsdotpm.github.io](https://robertsdotpm.github.io) 上,旨在解决在不依赖脚本或环境变量的情况下共享特定配置的问题。 然而,评论者大多表示怀疑。担忧包括版本控制的复杂性增加、难以发现可用选项(没有 `--help` 标志)以及管理不同配置的笨拙。一些人指出 Busybox 和 Python 的 `pip` 等现有先例使用类似的技术来处理入口点,而另一些人则强调传统标志对于清晰度和可用性的优势。 该方法的核心论点在于其自包含性——文件名*就是*配置,使其易于共享和移植。尽管如此,共识倾向于在大多数情况下,更喜欢使用诸如标志和脚本之类的成熟方法。
相关文章

原文

Programs usually get input from flags or scripts. But there’s another way: a program can read its own filename. That means the entire configuration can live in the file name itself, making programs self-contained, portable, and instantly shareable.

Why not just flags or scripts?

Flags are ephemeral – you have to share the command line or wrap it in a script. Scripts depend on environment, which can break portability. Filenames solve both: the program describes itself, requires zero setup, and any configuration can be shared by simply renaming the file.

Example 1: Reusable installers

Imagine install_PY3_MODULE_NAME.exe. It reads the filename, extracts the Python module name, downloads dependencies, sets up Python if needed, and creates a launcher. Rename it, and you have a new installer for a different project. Icons, mirrors, or other metadata can also live in the file as resources – all self-contained, all shareable.

See my exploration: here

Example 2: AI experiment runners

ML experiments usually require scripts, configs, and data setup. Imagine a single executable:

train---resnet50---lr0.001---batch32---cifar10.exe

It parses its filename, downloads datasets, sets hyperparameters, installs dependencies, and runs automatically. Rename it for a new model, dataset, or parameters.

Share the file, reproduce instantly.

Example 3: Ephemeral utilities

Small ad-hoc tasks can also be encoded in filenames:

compress---photos---high.exe
backup---home---encrypt-aes256.exe
fetch---api.github.com---repos/owner/project---q=stars>100---o=json.exe

Each file does its job immediately. Rename to perform a new task. Share it. No setup, no instructions. Everything is self-contained in the name.

Example 4: P2P VPN tunnels

VPNs between friends are usually tricky to set up. Imagine:

lounge-room---friends-machine---t25565---minecraft.exe
  • First two parts: machine names, automatically registered with a server using ECDSA keys.

  • Third part: ports to open.

  • Optional: description.

Run the file to open one side of the tunnel. Rename for new endpoints or ports. Send to a friend, they open their side, tunnel is connected, game on. No config, no editing, zero friction.

Closing thoughts

This approach collapses configuration, portability, and reproducibility into a single artifact. It challenges conventional assumptions: using filenames as the interface. For installers, AI experiments, utilities, or even VPNs, renaming the file is all it takes to change behavior.

联系我们 contact @ memedata.com