Add skip-sharing option and enhance user experince for sharing after recording
This commit is contained in:
@@ -167,6 +167,7 @@ Options
|
|||||||
```
|
```
|
||||||
-c, --config Overwrite the default configurations [string]
|
-c, --config Overwrite the default configurations [string]
|
||||||
-d, --command The command to be executed [string] [default: null]
|
-d, --command The command to be executed [string] [default: null]
|
||||||
|
-k, --skip-sharing Skip sharing and showing the sharing prompt message [boolean] [default: false]
|
||||||
```
|
```
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
|
|||||||
@@ -119,8 +119,10 @@ function onData(content) {
|
|||||||
/**
|
/**
|
||||||
* Executed after the command completes its task
|
* Executed after the command completes its task
|
||||||
* Store the output file with reserving the comments
|
* Store the output file with reserving the comments
|
||||||
|
*
|
||||||
|
* @param {Object} argv
|
||||||
*/
|
*/
|
||||||
function done() {
|
function done(argv) {
|
||||||
|
|
||||||
var outputYAML = '';
|
var outputYAML = '';
|
||||||
|
|
||||||
@@ -149,19 +151,43 @@ function done() {
|
|||||||
console.log(di.chalk.green('Successfully Recorded'));
|
console.log(di.chalk.green('Successfully Recorded'));
|
||||||
console.log('The recording data is saved into the file:');
|
console.log('The recording data is saved into the file:');
|
||||||
console.log(di.chalk.magenta(recordingFile));
|
console.log(di.chalk.magenta(recordingFile));
|
||||||
console.log('You can edit the file and even change the configurations.\n');
|
console.log('You can edit the file and even change the configurations.');
|
||||||
|
console.log(
|
||||||
console.log(di.chalk.green('Let\'s now share your recording on https://terminalizer.com'));
|
"The command " +
|
||||||
console.log('The command ' + di.chalk.magenta('`terminalizer share`') + 'can be used anytime to share recordings!\n');
|
di.chalk.magenta("`terminalizer share`") +
|
||||||
|
"can be used anytime to share recordings!"
|
||||||
|
);
|
||||||
|
|
||||||
// Reset STDIN
|
// Reset STDIN
|
||||||
process.stdin.removeAllListeners();
|
|
||||||
process.stdin.setRawMode(false);
|
process.stdin.setRawMode(false);
|
||||||
process.stdin.pause();
|
process.stdin.pause();
|
||||||
|
|
||||||
|
if (argv.skipSharing) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
di.inquirer.prompt([
|
||||||
|
{
|
||||||
|
type: "confirm",
|
||||||
|
name: "share",
|
||||||
|
message: "Would you like to share your recording on terminalizer.com?",
|
||||||
|
},
|
||||||
|
]).then(function(answers) {
|
||||||
|
|
||||||
|
if (!answers.share) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
di.chalk.green(
|
||||||
|
"Let's now share your recording on https://terminalizer.com"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Invoke the share command
|
// Invoke the share command
|
||||||
di.commands.share.handler({
|
di.commands.share.handler({
|
||||||
recordingFile: recordingFile
|
recordingFile: recordingFile,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -197,13 +223,18 @@ function command(argv) {
|
|||||||
env: di.deepmerge(process.env, config.json.env)
|
env: di.deepmerge(process.env, config.json.env)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var onInput = ptyProcess.write.bind(ptyProcess);
|
||||||
|
|
||||||
console.log('The recording session is started');
|
console.log('The recording session is started');
|
||||||
console.log('Press', di.chalk.green('CTRL+D'), 'to exit and save the recording');
|
console.log('Press', di.chalk.green('CTRL+D'), 'to exit and save the recording');
|
||||||
|
|
||||||
// Input and output capturing and redirection
|
// Input and output capturing and redirection
|
||||||
|
process.stdin.on('data', onInput);
|
||||||
ptyProcess.on('data', onData);
|
ptyProcess.on('data', onData);
|
||||||
ptyProcess.on('exit', done);
|
ptyProcess.on('exit', function() {
|
||||||
process.stdin.on('data', ptyProcess.write.bind(ptyProcess));
|
process.stdin.removeListener('data', onInput);
|
||||||
|
done(argv);
|
||||||
|
});
|
||||||
|
|
||||||
// Input and output normalization
|
// Input and output normalization
|
||||||
process.stdout.setDefaultEncoding('utf8');
|
process.stdout.setDefaultEncoding('utf8');
|
||||||
@@ -278,6 +309,15 @@ module.exports.builder = function(yargs) {
|
|||||||
default: null
|
default: null
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Define the config option
|
||||||
|
yargs.option('k', {
|
||||||
|
alias: 'skip-sharing',
|
||||||
|
type: 'boolean',
|
||||||
|
describe: 'Skip sharing and showing the sharing prompt message',
|
||||||
|
requiresArg: false,
|
||||||
|
default: false
|
||||||
|
});
|
||||||
|
|
||||||
// Add examples
|
// Add examples
|
||||||
yargs.example('$0 record foo', 'Start recording and create a recording file called foo.yml');
|
yargs.example('$0 record foo', 'Start recording and create a recording file called foo.yml');
|
||||||
yargs.example('$0 record foo --config config.yml', 'Start recording with your own configurations');
|
yargs.example('$0 record foo --config config.yml', 'Start recording with your own configurations');
|
||||||
|
|||||||
Reference in New Issue
Block a user