소스 검색

Config

- cli: getter
Alexey Kim 1 년 전
부모
커밋
0e034a5b50
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      config/iconfig.go

+ 9 - 0
config/iconfig.go

@@ -78,3 +78,12 @@ func LoadConfig[T IConfig](ctx *cli.Context, path cli.Path) error {
 	ctx.App.Metadata[cliMetaKey] = cfg
 	return nil
 }
+
+func Config[T IConfig](ctx *cli.Context) *T {
+	cfg, ok := ctx.App.Metadata["cli.config"].(*T)
+	if !ok {
+		return nil
+	}
+
+	return cfg
+}