diff --git a/src/cli/discourse.js b/src/cli/discourse.js index c8cc00c..805703e 100644 --- a/src/cli/discourse.js +++ b/src/cli/discourse.js @@ -78,15 +78,11 @@ const command: Command = async (args, std) => { return die(std, "Expected one positional arguments (or --help)."); } const [serverUrl] = positionalArgs; - let projectId = serverUrl; - if (projectId.startsWith("https://")) { - projectId = projectId.slice("https://".length); - } else if (projectId.startsWith("http://")) { - projectId = projectId.slice("http://".length); - } else { + const httpRE = new RegExp(/^https?:\/\//); + if (!httpRE.test(serverUrl)) { die(std, "expected server url to start with 'https://' or 'http://'"); } - + const projectId = serverUrl.trim().replace(httpRE, ""); const project: Project = { id: projectId, repoIds: [], diff --git a/src/cli/genProject.js b/src/cli/genProject.js index 806cb28..3d48bd3 100644 --- a/src/cli/genProject.js +++ b/src/cli/genProject.js @@ -20,7 +20,6 @@ function usage(print: (string) => void): void { usage: sourcecred gen-project PROJECT_ID [--github GITHUB_SPEC [...]] [--discourse-url DISCOURSE_URL] - [--discourse-username DISCOURSE_USERNAME] sourcecred gen-project --help Generates a SourceCred project configuration based on the provided specs.