@jakubmazanec/cli 0.1.0-265acad → 0.1.0-2f12db0

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.
Files changed (52) hide show
  1. package/dist/program/Command.d.ts +2 -2
  2. package/dist/program/Command.js +3 -3
  3. package/dist/program/Command.js.map +1 -1
  4. package/dist/program/CommandOptions.d.ts +1 -1
  5. package/dist/program/CommandOptions.js.map +1 -1
  6. package/dist/program/Program.d.ts +8 -3
  7. package/dist/program/Program.js +27 -7
  8. package/dist/program/Program.js.map +1 -1
  9. package/dist/program/ProgramOptions.d.ts +5 -1
  10. package/dist/program/ProgramOptions.js +1 -3
  11. package/dist/program/ProgramOptions.js.map +1 -1
  12. package/dist/program/ProgramStreams.d.ts +1 -1
  13. package/dist/program/ProgramStreams.js +1 -1
  14. package/dist/program/ProgramStreams.js.map +1 -1
  15. package/dist/ui/Failure.d.ts +2 -2
  16. package/dist/ui/Failure.js.map +1 -1
  17. package/dist/ui/Header.d.ts +1 -1
  18. package/dist/ui/Header.js.map +1 -1
  19. package/dist/ui/Help.d.ts +2 -2
  20. package/dist/ui/Help.js.map +1 -1
  21. package/dist/ui/form/SelectInput.d.ts +3 -3
  22. package/dist/ui/form/SelectInput.js +20 -29
  23. package/dist/ui/form/SelectInput.js.map +1 -1
  24. package/dist/ui/form/TextInput.d.ts +1 -1
  25. package/dist/ui/form/TextInput.js +4 -7
  26. package/dist/ui/form/TextInput.js.map +1 -1
  27. package/dist/ui/getErrorDetail.js +9 -0
  28. package/dist/ui/getErrorDetail.js.map +1 -1
  29. package/dist/ui/internals/Wrapper.d.ts +2 -2
  30. package/dist/ui/internals/Wrapper.js +1 -1
  31. package/dist/ui/internals/Wrapper.js.map +1 -1
  32. package/dist/ui/internals/programContext.d.ts +1 -1
  33. package/dist/ui/internals/programContext.js +1 -1
  34. package/dist/ui/internals/programContext.js.map +1 -1
  35. package/dist/ui/useProgram.d.ts +1 -1
  36. package/dist/ui/useProgram.js +1 -1
  37. package/dist/ui/useProgram.js.map +1 -1
  38. package/package.json +8 -7
  39. package/src/program/Command.ts +2 -3
  40. package/src/program/CommandOptions.ts +1 -1
  41. package/src/program/Program.ts +38 -5
  42. package/src/program/ProgramOptions.ts +7 -1
  43. package/src/program/ProgramStreams.ts +1 -1
  44. package/src/ui/Failure.tsx +2 -2
  45. package/src/ui/Header.tsx +1 -1
  46. package/src/ui/Help.tsx +2 -2
  47. package/src/ui/form/SelectInput.tsx +23 -28
  48. package/src/ui/form/TextInput.tsx +5 -10
  49. package/src/ui/getErrorDetail.ts +11 -0
  50. package/src/ui/internals/Wrapper.tsx +2 -2
  51. package/src/ui/internals/programContext.ts +1 -1
  52. package/src/ui/useProgram.ts +1 -1
@@ -1,4 +1,6 @@
1
1
  import {ValidationError, ParsingError} from '@jakubmazanec/args';
2
+ import {zodIssuesToStrings} from '@jakubmazanec/zod-utils';
3
+ import {ZodError} from 'zod';
2
4
 
3
5
  import {type ErrorDetail} from './ErrorDetail.js';
4
6
 
@@ -44,6 +46,15 @@ export function getErrorDetail(error: unknown): ErrorDetail {
44
46
  return errorDetail;
45
47
  }
46
48
 
49
+ if (error instanceof ZodError) {
50
+ let errorDetail: ErrorDetail = {
51
+ label: 'Error',
52
+ description: zodIssuesToStrings(error.issues).join('\n'),
53
+ };
54
+
55
+ return errorDetail;
56
+ }
57
+
47
58
  if (error instanceof Error) {
48
59
  let errorDetail: ErrorDetail = {
49
60
  label: 'Error',
@@ -7,14 +7,14 @@ import {type Program} from '../../program.js';
7
7
  import {Failure} from '../Failure.js';
8
8
 
9
9
  /**
10
- * {@linkcode Wrapper} component props.
10
+ * {@link Wrapper} component props.
11
11
  */
12
12
  export type WrapperProps = {
13
13
  program: Program;
14
14
  };
15
15
 
16
16
  /**
17
- * A component that wraps anything {@linkcode Program} tries to render with an error boundary and all neccessary providers.
17
+ * A component that wraps anything {@link Program} tries to render with an error boundary and all neccessary providers.
18
18
  */
19
19
  export const Wrapper: FC<PropsWithChildren<WrapperProps>> = ({program, children}) => {
20
20
  let programContextValue = useMemo(
@@ -7,6 +7,6 @@ export type ProgramContext = {
7
7
  };
8
8
 
9
9
  /**
10
- * A React context that stores {@linkcode Program} instance.
10
+ * A React context that stores {@link Program} instance.
11
11
  */
12
12
  export const programContext = React.createContext<ProgramContext>({} as ProgramContext);
@@ -5,7 +5,7 @@ import {useErrorBoundary} from 'react-error-boundary';
5
5
  import {programContext} from './internals.js';
6
6
 
7
7
  /**
8
- * A React hook for accessing {@linkcode Program} instance and `exit` function that is used for showing an error (via an error boundary) and exiting.
8
+ * A React hook for accessing {@link Program} instance and `exit` function that is used for showing an error (via an error boundary) and exiting.
9
9
  */
10
10
  export function useProgram() {
11
11
  let {showBoundary} = useErrorBoundary();