Skip to content

Commit

Permalink
Fixed file+page with positional args
Browse files Browse the repository at this point in the history
  • Loading branch information
stooit committed Nov 25, 2024
1 parent f9e22f0 commit 0ecd435
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
22 changes: 14 additions & 8 deletions src/commands/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,24 @@ const command = {
.example('quant file image.jpg /images/header.jpg', 'Deploy an image');
},

async promptArgs() {
const file = await text({
message: 'Enter path to local file',
async promptArgs(providedArgs = {}) {
let file = providedArgs.file;
if (!file) {
file = await text({
message: 'Enter path to local file',
validate: value => !value ? 'File path is required' : undefined
});
if (isCancel(file)) return null;
});
if (isCancel(file)) return null;
}

const location = await text({
let location = providedArgs.location;
if (!location) {
location = await text({
message: 'Enter the access URI (where the file will be available)',
validate: value => !value ? 'Location is required' : undefined
});
if (isCancel(location)) return null;
});
if (isCancel(location)) return null;
}

return { file, location };
},
Expand Down
22 changes: 14 additions & 8 deletions src/commands/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,24 @@ const command = {
.example('quant page about.html /about --enable-index-html', 'Deploy with index.html suffix');
},

async promptArgs() {
const file = await text({
message: 'Enter path to local HTML file',
async promptArgs(providedArgs = {}) {
let file = providedArgs.file;
if (!file) {
file = await text({
message: 'Enter path to local HTML file',
validate: value => !value ? 'File path is required' : undefined
});
if (isCancel(file)) return null;
});
if (isCancel(file)) return null;
}

const location = await text({
let location = providedArgs.location;
if (!location) {
location = await text({
message: 'Enter the access URI (where the page will be available)',
validate: value => !value ? 'Location is required' : undefined
});
if (isCancel(location)) return null;
});
if (isCancel(location)) return null;
}

return { file, location };
},
Expand Down

0 comments on commit 0ecd435

Please sign in to comment.