@jinshuju/cli 0.31.0 → 0.32.0

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.
@@ -126,11 +126,21 @@ export const COMMANDS = [
126
126
  ...ARTIFACT
127
127
  ];
128
128
  /**
129
- * Words that name the same verb. Some resources delete and others remove, after
130
- * what the API calls it, and nobody remembers which; either one reaches the
131
- * command, and the one written out still wins where both exist.
129
+ * Words that name the same verb. Some resources delete and others remove, some
130
+ * edit and others update, after what the API calls it, and nobody remembers
131
+ * which; any word of a group reaches the command, and the one written out still
132
+ * wins where both exist. No resource has two of one group, and every update or
133
+ * edit changes only what it names, so a synonym never lands on a command that
134
+ * does more than the word said.
132
135
  */
133
- const SAME_VERB = { delete: 'remove', remove: 'delete' };
136
+ const VERB_GROUPS = [
137
+ ['delete', 'remove'],
138
+ ['create', 'add'],
139
+ ['update', 'edit'],
140
+ ['get', 'show'],
141
+ ['list', 'ls']
142
+ ];
143
+ const SAME_VERB = new Map(VERB_GROUPS.flatMap((group) => group.map((word) => [word, group.filter((other) => other !== word)])));
134
144
  /** The command whose path the words begin with, longest match first; a spelled-out match beats a synonym. */
135
145
  export function findCommand(words, commands = COMMANDS) {
136
146
  let best;
@@ -138,7 +148,7 @@ export function findCommand(words, commands = COMMANDS) {
138
148
  for (const command of commands) {
139
149
  if (command.path.length > words.length)
140
150
  continue;
141
- const parts = command.path.map((part, index) => words[index] === part ? 'exact' : SAME_VERB[words[index]] === part ? 'synonym' : 'miss');
151
+ const parts = command.path.map((part, index) => words[index] === part ? 'exact' : SAME_VERB.get(words[index])?.includes(part) ? 'synonym' : 'miss');
142
152
  if (parts.includes('miss'))
143
153
  continue;
144
154
  const exact = !parts.includes('synonym');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinshuju/cli",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "Command line interface for Jinshuju Open API v1",
5
5
  "homepage": "https://github.com/jinshuju/cli#readme",
6
6
  "bugs": {