Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/src/quarto-core/profile.ts
3557 views
1
/*
2
* profile.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*/
6
7
import { Args } from "flags";
8
import { Command } from "cliffy/command/mod.ts";
9
10
export const kQuartoProfile = "QUARTO_PROFILE";
11
12
export function activeProfiles(): string[] {
13
return readProfile(Deno.env.get(kQuartoProfile));
14
}
15
16
export function readProfile(profile?: string) {
17
if (profile) {
18
return profile.split(/[ ,]+/);
19
} else {
20
return [];
21
}
22
}
23
24
export function setProfileFromArg(args: Args) {
25
// set profile if specified
26
if (args.profile) {
27
Deno.env.set(kQuartoProfile, args.profile);
28
return true;
29
} else {
30
return false;
31
}
32
}
33
34
// deno-lint-ignore no-explicit-any
35
export function appendProfileArg(cmd: Command<any>): Command<any> {
36
return cmd.option(
37
"--profile",
38
"Active project profile(s)",
39
{
40
global: true,
41
},
42
);
43
}
44
45