Skip to content

Instantly share code, notes, and snippets.

async handler(argv, {console, describe, options, style}) {
// Print command description
console.important(describe);
// Prompt user for option or use default
const value = await console.cli.require(options.val);
// Print 'value' with style and color
console.log('value:', style.bold.cyan(value), style.gray(argv.val));
}
@RubaXa
RubaXa / cli.test.ts
Created May 30, 2021 12:21
CLI: Тестовая команда
import {createCommand} from '@mail-core/cli';
export const test = createCommand({
name: 'test',
describe: 'Тестовая команда',
options: {
val: {
desc: 'Any value',
type: 'string',
@RubaXa
RubaXa / global.ts
Last active June 3, 2020 19:46
globalThis globalLocation &
export const noop = () => {};
export const nativeGlobalThis = (0
|| typeof globalThis === 'object' && globalThis
|| typeof window === 'object' && window
|| typeof global === 'object' && global
|| {}
) as Window;
export const globalLocation = nativeGlobalThis.location || {
package main
import (
"fmt"
"log"
"github.com/gothing/draft"
"github.com/gothing/draft-demo/auth"
)
// InitEndpointScheme - инициализация описания «конца»
func (a *AuthLogin) InitEndpointScheme(s *draft.Scheme) {
// Проект, которому принадлежит «конец»
s.Project("auth")
// Метод доступен всем
s.Access(draft.Access.All)
// Базовый метод для всех кейсов
s.Method(draft.Method.POST)
// AuthLoginResponse — ответ на запрос
type AuthLoginResponse struct {
// инлайн комментарий с наследованием родительского
UserID types.UserID `comment:"{super}, авторизованного пользователя"`
}
package types
type Login string
func (v Login) TypeDescription() string {
return "Login пользователя (он же email, телефон или соц. аккаунт)"
}
func GenLogin() Login {
return "fast.test@mail.ru"
type Key = string;
type Val = string | number;
type KeyValue<
K extends Key,
P extends Key, // Дополнительные поля (!)
V extends Val,
> = (
& Record<K, V>
& Record<P, any>
);
type Key = string;
type Val = string | number;
type KeyValue<K extends Key, V extends Val> = {
[X in K]: V;
}
type CompostedObject<KEY extends Key, T extends KeyValue<KEY, Val>[]> =
FlattenObject<
ToIntersect<
{
[K in keyof T]: T[K] extends KeyValue<KEY, Val>
type Primitive = string | number | boolean | null;
type Token<N extends string, V extends Primitive> = {
name: N;
value: V;
}
type TokensDict<T extends Token<any, any>[]> =
FlattenObject<
ToIntersect<