What is Hackers' Pub?

Hackers' Pub is a place for software engineers to share their knowledge and experience with each other. It's also an ActivityPub-enabled social network, so you can follow your favorite hackers in the fediverse and get their latest posts in your feed.

1
1
0
0
0
0
0
0

🍝 저의 주님, 날아다니는 스파게티 괴물 님, 저를 보호하시어 살펴주소서.
😋 어서 구원하시어 혼자 내버려 두지 마소서.

🍝 날아다니는 스파게티 괴물 님께서 여러분과 함께.
😋 또한 주교의 면발과 함께 하소서.
🍝 기도합시다.
지극히 선하신 스파게티 괴물 님, 사람들이 더욱더 완전한 것을 이루기 위해서 서로 협조하여 일하게 해주셨으니,
저희 기도를 들으시고 저희가 항상 우정을 품고, 모든 이들을 위한 박애로 끊임없이 일하게 하소서.

"4. 성면의 인도 아래, 저희가 헛된 분주함이 아니라 의미 있는 일에 마음을 두게 하소서."

🍝 날아다니는 스파게티 괴물 님께서 여러분과 함께.
😋 또한 주교의 면발과 함께 하소서.
🍝 전능하신 스파게티 괴물 님, 미트볼🧆과 소스🥫와 성면(the Holy Noodle)🍝께서는 여기 모인 모든 이에게 강복하소서.
😋 라-멘 🍜.

🍝 날아다니는 스파게티 괴물 님을 찬미합시다.
😋 주님 감사합니다.

2026-01-13T14:02:19+09:00


0

土曜に車の暗電流を測定したんだけど、オートACC動作中は1.5A超え(!?)で全部切れたあとは30mAぐらいだった オートACCってセカンドバッテリから供給されると思ってたんだけど、死にかけとかなのかねえ

0
0
0
0
0
0
0
0
0
0

저는 세션 출발 전 캐릭터의 백그라운드를 짜놓는 걸… 일종의 청사진과 플레이를 할 때의 나를 위한 RP가이드를 만들어놓는다는 느낌으로 생각하고 있어요.

그래서 인제 플 들어가면 실제 청사진과 다른 부분이 생기기도, 청사진대로 굴러가는 부분이 생기기도 하는거지요.

0
1

세상의 온갖 불의에 하나하나 화가 날 때면, 그 불의가 모두 해소되는 날은 절대로 오지 않는다는 사실을 되뇌이며 마음을 가라앉힐 필요도 있다고 본다. 그런 이상적 상태는 설령 전지적 만족자인 내게 전능의 힘이 주어진다고 해도 얻어지는 것이 아니기 때문이다.

0
1
1
0
0

[단독]공정위, 쿠팡 본사 대대적 현장조사…‘총수 지정·플랫폼 지위 악용’ 정조준 www.khan.co.kr/article/2026... “13일 업계에 따르면 공정위 기업집단국·시장감시국·유통대리점국은 이날 오전 서울 송파구 쿠팡 본사에 조사관을 파견해 관련 자료 확보에 나섰다. 통상 특정 부서가 조사를 주도하는 것과 달리, 이번에는 기업집단국을 포함한 3개국이 동시에 투입됐다는 점에서 조사 강도가 매우 높다는 분석이 나온다.”

[단독]공정위, 쿠팡 본사 대대적 현장조사…‘총수 지정...

0

Your CLI's completion should know what options you've already typed

洪 民憙 (Hong Minhee) @hongminhee@hackers.pub

Consider Git's -C option:

git -C /path/to/repo checkout <TAB>

When you hit Tab, Git completes branch names from /path/to/repo, not your current directory. The completion is context-aware—it depends on the value of another option.

Most CLI parsers can't do this. They treat each option in isolation, so completion for --branch has no way of knowing the --repo value. You end up with two unpleasant choices: either show completions for all possible branches across all repositories (useless), or give up on completion entirely for these options.

Optique 0.10.0 introduces a dependency system that solves this problem while preserving full type safety.

Static dependencies with or()

Optique already handles certain kinds of dependent options via the or() combinator:

import { flag, object, option, or, string } from "@optique/core";

const outputOptions = or(
  object({
    json: flag("--json"),
    pretty: flag("--pretty"),
  }),
  object({
    csv: flag("--csv"),
    delimiter: option("--delimiter", string()),
  }),
);

TypeScript knows that if json is true, you'll have a pretty field, and if csv is true, you'll have a delimiter field. The parser enforces this at runtime, and shell completion will suggest --pretty only when --json is present.

This works well when the valid combinations are known at definition time. But it can't handle cases where valid values depend on runtime input—like branch names that vary by repository.

Runtime dependencies

Common scenarios include:

  • A deployment CLI where --environment affects which services are available
  • A database tool where --connection affects which tables can be completed
  • A cloud CLI where --project affects which resources are shown

In each case, you can't know the valid values until you know what the user typed for the dependency option. Optique 0.10.0 introduces dependency() and derive() to handle exactly this.

The dependency system

The core idea is simple: mark one option as a dependency source, then create derived parsers that use its value.

import {
  choice,
  dependency,
  message,
  object,
  option,
  string,
} from "@optique/core";

function getRefsFromRepo(repoPath: string): string[] {
  // In real code, this would read from the Git repository
  return ["main", "develop", "feature/login"];
}

// Mark as a dependency source
const repoParser = dependency(string());

// Create a derived parser
const refParser = repoParser.derive({
  metavar: "REF",
  factory: (repoPath) => {
    const refs = getRefsFromRepo(repoPath);
    return choice(refs);
  },
  defaultValue: () => ".",
});

const parser = object({
  repo: option("--repo", repoParser, {
    description: message`Path to the repository`,
  }),
  ref: option("--ref", refParser, {
    description: message`Git reference`,
  }),
});

The factory function is where the dependency gets resolved. It receives the actual value the user provided for --repo and returns a parser that validates against refs from that specific repository.

Under the hood, Optique uses a three-phase parsing strategy:

  1. Parse all options in a first pass, collecting dependency values
  2. Call factory functions with the collected values to create concrete parsers
  3. Re-parse derived options using those dynamically created parsers

This means both validation and completion work correctly—if the user has already typed --repo /some/path, the --ref completion will show refs from that path.

Repository-aware completion with @optique/git

The @optique/git package provides async value parsers that read from Git repositories. Combined with the dependency system, you can build CLIs with repository-aware completion:

import {
  command,
  dependency,
  message,
  object,
  option,
  string,
} from "@optique/core";
import { gitBranch } from "@optique/git";

const repoParser = dependency(string());

const branchParser = repoParser.deriveAsync({
  metavar: "BRANCH",
  factory: (repoPath) => gitBranch({ dir: repoPath }),
  defaultValue: () => ".",
});

const checkout = command(
  "checkout",
  object({
    repo: option("--repo", repoParser, {
      description: message`Path to the repository`,
    }),
    branch: option("--branch", branchParser, {
      description: message`Branch to checkout`,
    }),
  }),
);

Now when you type my-cli checkout --repo /path/to/project --branch <TAB>, the completion will show branches from /path/to/project. The defaultValue of "." means that if --repo isn't specified, it falls back to the current directory.

Multiple dependencies

Sometimes a parser needs values from multiple options. The deriveFrom() function handles this:

import {
  choice,
  dependency,
  deriveFrom,
  message,
  object,
  option,
} from "@optique/core";

function getAvailableServices(env: string, region: string): string[] {
  return [`${env}-api-${region}`, `${env}-web-${region}`];
}

const envParser = dependency(choice(["dev", "staging", "prod"] as const));
const regionParser = dependency(choice(["us-east", "eu-west"] as const));

const serviceParser = deriveFrom({
  dependencies: [envParser, regionParser] as const,
  metavar: "SERVICE",
  factory: (env, region) => {
    const services = getAvailableServices(env, region);
    return choice(services);
  },
  defaultValues: () => ["dev", "us-east"] as const,
});

const parser = object({
  env: option("--env", envParser, {
    description: message`Deployment environment`,
  }),
  region: option("--region", regionParser, {
    description: message`Cloud region`,
  }),
  service: option("--service", serviceParser, {
    description: message`Service to deploy`,
  }),
});

The factory receives values in the same order as the dependency array. If some dependencies aren't provided, Optique uses the defaultValues.

Async support

Real-world dependency resolution often involves I/O—reading from Git repositories, querying APIs, accessing databases. Optique provides async variants for these cases:

import { dependency, string } from "@optique/core";
import { gitBranch } from "@optique/git";

const repoParser = dependency(string());

const branchParser = repoParser.deriveAsync({
  metavar: "BRANCH",
  factory: (repoPath) => gitBranch({ dir: repoPath }),
  defaultValue: () => ".",
});

The @optique/git package uses isomorphic-git under the hood, so gitBranch(), gitTag(), and gitRef() all work in both Node.js and Deno.

There's also deriveSync() for when you need to be explicit about synchronous behavior, and deriveFromAsync() for multiple async dependencies.

Wrapping up

The dependency system lets you build CLIs where options are aware of each other—not just for validation, but for shell completion too. You get type safety throughout: TypeScript knows the relationship between your dependency sources and derived parsers, and invalid combinations are caught at compile time.

This is particularly useful for tools that interact with external systems where the set of valid values isn't known until runtime. Git repositories, cloud providers, databases, container registries—anywhere the completion choices depend on context the user has already provided.

This feature will be available in Optique 0.10.0. To try the pre-release:

deno add jsr:@optique/core@0.10.0-dev.311

Or with npm:

npm install @optique/core@0.10.0-dev.311

See the documentation for more details.

Read more →
5

세상 사람들 모두가 나만큼은 멍청하다는 사실을 의식적으로 계속 머리속에 주입하고 살면, 상당히 많은 스트레스가 예방되는 것 같다. 때로 어떤 정상성과 유능함이라는 건 유물론적으로 존재할 수 없는 신앙적 상상에 머물고 만다는 점을 인정하고 나면, 온갖 헛된 기대와 망념에서 일부 벗어날 수 있다.

0
0
0
0
0
1
0

[이상규 모두를위한서울특위장 브리핑] 서울버스파업 사태, 수수방관하는 서울시를 규탄한다. jinboparty.com/pages/?p=15&... 오늘 버스파업 사태로 시민들의 불편을 겪게 한 서울시를 강력히 규탄합니다. 첫째, 법적 의무를 ‘협상 카드’로 미루는 서울시의 고질적 병폐가 문제입니다. 둘째, 준공영제의 실질 책임자가 뒤로 빠지는 태도가 문제입니다. 셋째, 시민 불편을 이용한 갈라치기, 오세훈 시장의 전형적 수법이자 나쁜 정치가 문제입니다.

0
0
0
0
0
0
0
0
0
0

英國足總杯第四輪抽籤
Wrexham對Ipswitch Town

Wrexham是死侍Ryan Reynolds的球隊,Ipswitch是Ed Sheeran的球隊

Disney+有一部紀錄片說死侍如何救了Wrexham這隊本來一片絕望的球隊;Ipswitch則是把17號留給Ed這位東家

0

いまじゃもうたぶんけっこうなレアものになってると思う、自分的宝物のマイベスト映画『楽園の瑕』初日本上映時のパンフ、やっと額に入れた。飾るぜ。
このドイルカメラの深い青とコントラストが自分の一つの理想なんだよなー。もちろん中身的にもだけど。
そしてレスリー・チャンよ永遠に。

1
0
0
1
0
1
0
0