faces-cli 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,6 @@ export default class StyleDelete extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
- scope: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
6
  yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
7
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
8
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -3,26 +3,28 @@ import { createInterface } from 'node:readline';
3
3
  import { BaseCommand } from '../../base.js';
4
4
  import { FacesAPIError } from '../../client.js';
5
5
  import { STYLE_FACES_PATH } from '../../style.js';
6
- /** What each scope destroys, in the words the user needs before choosing. */
7
- const SCOPES = {
8
- map: 'the captured style and everything derived from it. Your uploaded material is kept, so it can be captured again without re-uploading.',
9
- all: 'the captured style AND the material it was built from. The uploaded corpus is deleted. This cannot be undone and nothing can rebuild it.',
10
- };
6
+ /**
7
+ * The API takes a scope: `map` clears the captured style, `all` clears it and
8
+ * destroys the uploaded material with it. This CLI only ever sends `map`.
9
+ *
10
+ * Nothing that removes a style should be able to take source text with it. A
11
+ * user reaching for "delete the style" is not asking to lose the writing it was
12
+ * learned from, and the two are one keystroke apart on the same command. Source
13
+ * text is deleted through the commands that own it — compile:doc:delete and
14
+ * compile:thread:delete — where that is the whole point of the call rather than
15
+ * a side effect of a flag value.
16
+ */
17
+ const SCOPE = 'map';
11
18
  export default class StyleDelete extends BaseCommand {
12
- static description = 'Delete a face\'s captured style. --scope map forgets the style and keeps the material it came from. ' +
13
- '--scope all deletes the uploaded material too, permanently. There is no default because the two ' +
14
- 'differ by whether your material survives.';
19
+ static description = "Delete a face's captured style. The material it was learned from is kept, so the style can be " +
20
+ 'captured again without re-uploading. This never deletes documents or threads: remove those with ' +
21
+ 'compile:doc:delete or compile:thread:delete.';
15
22
  static examples = [
16
- '<%= config.bin %> <%= command.id %> alice --scope map',
17
- '<%= config.bin %> <%= command.id %> alice --scope all --yes',
23
+ '<%= config.bin %> <%= command.id %> alice',
24
+ '<%= config.bin %> <%= command.id %> alice --yes',
18
25
  ];
19
26
  static flags = {
20
27
  ...BaseCommand.baseFlags,
21
- scope: Flags.string({
22
- description: 'map: forget the style, keep the material. all: delete the material with it, permanently.',
23
- options: ['map', 'all'],
24
- required: true,
25
- }),
26
28
  yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
27
29
  };
28
30
  static args = {
@@ -31,32 +33,32 @@ export default class StyleDelete extends BaseCommand {
31
33
  async run() {
32
34
  const { args, flags } = await this.parse(StyleDelete);
33
35
  const client = this.makeClient(flags);
34
- const scope = flags.scope;
35
36
  if (!flags.yes) {
36
- const what = `This deletes ${SCOPES[scope]}`;
37
+ const what = `'${args.alias}' will forget its captured style. Its documents, threads and uploaded material are kept.`;
37
38
  if (this.jsonEnabled())
38
39
  this.error(`${what}\nRe-run with --yes to confirm.`);
39
- const ok = await this.confirm(`${what}\nDelete for '${args.alias}'?`);
40
+ const ok = await this.confirm(`${what}\nDelete the style?`);
40
41
  if (!ok)
41
42
  this.error('Aborted. Nothing was deleted.');
42
43
  }
43
44
  let data;
44
45
  try {
45
- data = await client.delete(`${STYLE_FACES_PATH}/${encodeURIComponent(args.alias)}?scope=${scope}`);
46
+ data = await client.delete(`${STYLE_FACES_PATH}/${encodeURIComponent(args.alias)}?scope=${SCOPE}`);
46
47
  }
47
48
  catch (err) {
48
49
  if (err instanceof FacesAPIError) {
49
50
  if (err.statusCode === 404)
50
51
  this.error(`No face named '${args.alias}'. It does not exist, or is not yours.`);
52
+ if (err.statusCode === 409)
53
+ this.error(`Error (409): ${err.message}\nThe face may be locked. Unlock it first.`);
51
54
  this.error(`Error (${err.statusCode}): ${err.message}`);
52
55
  }
53
56
  throw err;
54
57
  }
55
58
  if (this.jsonEnabled())
56
59
  return data;
57
- this.log(scope === 'all'
58
- ? `Deleted the style and the uploaded material for '${args.alias}'.`
59
- : `Deleted the style for '${args.alias}'. The material it came from is still there, so you can capture it again: faces style:make ${args.alias} --all`);
60
+ this.log(`'${args.alias}' has forgotten its style. Its source material is untouched.`);
61
+ this.log(`Capture it again with: faces style:make ${args.alias} --all`);
60
62
  return data;
61
63
  }
62
64
  confirm(message) {