diff options
Diffstat (limited to 'src/data/things/group.js')
-rw-r--r-- | src/data/things/group.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/data/things/group.js b/src/data/things/group.js index 294c02c6..4b4c306c 100644 --- a/src/data/things/group.js +++ b/src/data/things/group.js @@ -1,5 +1,8 @@ export const GROUP_DATA_FILE = 'groups.yaml'; +import {inspect} from 'node:util'; + +import {colors} from '#cli'; import {input} from '#composite'; import Thing from '#thing'; import {is} from '#validators'; @@ -285,4 +288,31 @@ export class Series extends Thing { 'Albums': {property: 'albums'}, }, }; + + [inspect.custom](depth, options, inspect) { + const parts = []; + + parts.push(Thing.prototype[inspect.custom].apply(this)); + + if (depth >= 0) showGroup: { + let group = null; + try { + group = this.group; + } catch { + break showGroup; + } + + const groupName = group.name; + const groupIndex = group.serieses.indexOf(this); + + const num = + (groupIndex === -1 + ? 'indeterminate position' + : `#${groupIndex + 1}`); + + parts.push(` (${colors.yellow(num)} in ${colors.green(`"${groupName}"`)})`); + } + + return parts.join(''); + } } |