Skip to content

Commit

Permalink
chore: add support for deno v0.42.0
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed May 3, 2020
1 parent df2221e commit cddb7d1
Show file tree
Hide file tree
Showing 63 changed files with 261 additions and 324 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -4,7 +4,7 @@ A collection of modules for creating interactive command line tools.

![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/c4spar/deno-cliffy?logo=github) ![GitHub Release Date](https://img.shields.io/github/release-date/c4spar/deno-cliffy?logo=github)

![Build Status](https://github.com/c4spar/deno-cliffy/workflows/ci/badge.svg?branch=master) ![Deno version](https://img.shields.io/badge/deno-v0.41.0|v0.40.0|v0.39.0-green?logo=deno) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/c4spar/deno-cliffy?logo=github) ![GitHub issues](https://img.shields.io/github/issues/c4spar/deno-cliffy?logo=github) ![GitHub licence](https://img.shields.io/github/license/c4spar/deno-cliffy?logo=github)
![Build Status](https://github.com/c4spar/deno-cliffy/workflows/ci/badge.svg?branch=master) ![Deno version](https://img.shields.io/badge/deno-v0.42.0-green?logo=deno) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/c4spar/deno-cliffy?logo=github) ![GitHub issues](https://img.shields.io/github/issues/c4spar/deno-cliffy?logo=github) ![GitHub licence](https://img.shields.io/github/license/c4spar/deno-cliffy?logo=github)

**Included modules:**

Expand Down
2 changes: 1 addition & 1 deletion packages/ansi-escape/README.md
Expand Up @@ -4,7 +4,7 @@ ANSI escape module for handling cli cursor, erase output and scroll window.

![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/c4spar/deno-cliffy?logo=github) ![GitHub Release Date](https://img.shields.io/github/release-date/c4spar/deno-cliffy?logo=github)

![Build Status](https://github.com/c4spar/deno-cliffy/workflows/ci/badge.svg?branch=master) ![Deno version](https://img.shields.io/badge/deno-v0.41.0|v0.40.0|v0.39.0-green?logo=deno) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/c4spar/deno-cliffy?logo=github) ![GitHub issues](https://img.shields.io/github/issues/c4spar/deno-cliffy?logo=github) ![GitHub licence](https://img.shields.io/github/license/c4spar/deno-cliffy?logo=github)
![Build Status](https://github.com/c4spar/deno-cliffy/workflows/ci/badge.svg?branch=master) ![Deno version](https://img.shields.io/badge/deno-v0.42.0-green?logo=deno) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/c4spar/deno-cliffy?logo=github) ![GitHub issues](https://img.shields.io/github/issues/c4spar/deno-cliffy?logo=github) ![GitHub licence](https://img.shields.io/github/license/c4spar/deno-cliffy?logo=github)

## Usage

Expand Down
6 changes: 3 additions & 3 deletions packages/ansi-escape/lib/ansi-escape.ts
@@ -1,14 +1,14 @@
import { encode } from 'https://deno.land/std@v0.41.0/encoding/utf8.ts';
import { encode } from 'https://deno.land/std@v0.42.0/encoding/utf8.ts';
import { cursor, erase, image, ImageOptions, link, scroll } from './csi.ts';

export class AnsiEscape {

/** Create instance from file. */
public static from( file: Deno.File ): AnsiEscape {
public static from( file: Deno.WriterSync ): AnsiEscape {
return new this( file );
}

protected constructor( protected file: Deno.File ) {}
protected constructor( protected file: Deno.WriterSync ) {}

/** Write to file. */
public write( code: string ): this {
Expand Down
2 changes: 1 addition & 1 deletion packages/command/README.md
Expand Up @@ -6,7 +6,7 @@ The complete solution for [Deno](https://deno.land/) command-line interfaces, in

![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/c4spar/deno-cliffy?logo=github) ![GitHub Release Date](https://img.shields.io/github/release-date/c4spar/deno-cliffy?logo=github)

![Build Status](https://github.com/c4spar/deno-cliffy/workflows/ci/badge.svg?branch=master) ![Deno version](https://img.shields.io/badge/deno-v0.41.0|v0.40.0|v0.39.0-green?logo=deno) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/c4spar/deno-cliffy?logo=github) ![GitHub issues](https://img.shields.io/github/issues/c4spar/deno-cliffy?logo=github) ![GitHub licence](https://img.shields.io/github/license/c4spar/deno-cliffy?logo=github)
![Build Status](https://github.com/c4spar/deno-cliffy/workflows/ci/badge.svg?branch=master) ![Deno version](https://img.shields.io/badge/deno-v0.42.0-green?logo=deno) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/c4spar/deno-cliffy?logo=github) ![GitHub issues](https://img.shields.io/github/issues/c4spar/deno-cliffy?logo=github) ![GitHub licence](https://img.shields.io/github/license/c4spar/deno-cliffy?logo=github)

### ✨ Features

Expand Down
2 changes: 1 addition & 1 deletion packages/command/commands/completions.ts
@@ -1,4 +1,4 @@
import { bold, dim, italic } from 'https://deno.land/std@v0.41.0/fmt/colors.ts';
import { bold, dim, italic } from 'https://deno.land/std@v0.42.0/fmt/colors.ts';
import { BaseCommand } from '../lib/base-command.ts';
import { DefaultCommand } from '../lib/default-command.ts';
import { BashCompletionsCommand } from './completions/bash.ts';
Expand Down
2 changes: 1 addition & 1 deletion packages/command/commands/help.ts
@@ -1,4 +1,4 @@
import { blue, bold, dim, green, magenta, red, yellow } from 'https://deno.land/std@v0.41.0/fmt/colors.ts';
import { blue, bold, dim, green, magenta, red, yellow } from 'https://deno.land/std@v0.42.0/fmt/colors.ts';
import { IFlagOptions, IFlags } from '../../flags/lib/types.ts';
import { Table } from '../../table/lib/table.ts';
import format from '../../x/format.ts';
Expand Down
11 changes: 7 additions & 4 deletions packages/command/lib/base-command.ts
@@ -1,6 +1,6 @@
const { stdout, stderr } = Deno;
import { encode } from 'https://deno.land/std@v0.41.0/encoding/utf8.ts';
import { dim, red } from 'https://deno.land/std@v0.41.0/fmt/colors.ts';
import { encode } from 'https://deno.land/std@v0.42.0/encoding/utf8.ts';
import { dim, red } from 'https://deno.land/std@v0.42.0/fmt/colors.ts';
import { parseFlags } from '../../flags/lib/flags.ts';
import { IFlagArgument, IFlagOptions, IFlags, IFlagsResult, IFlagValue, IFlagValueHandler, IFlagValueType, IGenericObject, ITypeHandler, OptionType } from '../../flags/lib/types.ts';
import { fill } from '../../flags/lib/utils.ts';
Expand Down Expand Up @@ -588,7 +588,8 @@ export class BaseCommand {
return;
}

const denoEnv = Deno.env();
// @TODO: check for permissions and use Deno.env.get()
const denoEnv = Deno.env.toObject();

this.envVars.forEach( ( env: IEnvVariable ) => {
const name = env.names.find( name => name in denoEnv );
Expand Down Expand Up @@ -784,6 +785,8 @@ export class BaseCommand {
return option;
}
}

return;
}

/********************************************************************************
Expand Down Expand Up @@ -1128,7 +1131,7 @@ export class BaseCommand {
return error;
}

const { CLIFFY_DEBUG } = hasEnvPermissions ? Deno.env() : {} as any;
const CLIFFY_DEBUG: boolean = hasEnvPermissions ? !!Deno.env.get( 'CLIFFY_DEBUG' ) : false;

showHelp && this.help();
this.logError( CLIFFY_DEBUG ? error : error.message );
Expand Down
6 changes: 3 additions & 3 deletions packages/command/test/command/allow-empty_test.ts
@@ -1,7 +1,7 @@
import { Command } from '../../lib/command.ts';
import { assertEquals, assertThrowsAsync } from '../lib/assert.ts';

Deno.test( async function flags_allowEmpty_enabled() {
Deno.test( 'flags allowEmpty enabled', async () => {

const { options, args } = await new Command()
.throwErrors()
Expand All @@ -14,7 +14,7 @@ Deno.test( async function flags_allowEmpty_enabled() {
assertEquals( args, [] );
} );

Deno.test( async function flags_allowEmpty_disabledNoFlags() {
Deno.test( 'flags allowEmpty disabledNoFlags', async () => {

const { options, args } = await new Command()
.throwErrors()
Expand All @@ -26,7 +26,7 @@ Deno.test( async function flags_allowEmpty_disabledNoFlags() {
assertEquals( args, [] );
} );

Deno.test( async function flags_allowEmpty_disabled() {
Deno.test( 'flags allowEmpty disabled', async () => {

const cmd = new Command()
.throwErrors()
Expand Down
12 changes: 6 additions & 6 deletions packages/command/test/command/sub-command_test.ts
Expand Up @@ -22,7 +22,7 @@ function command( states: any = {} ): Command {
.action( () => { states.action3 = true; } ) );
}

Deno.test( async function command_subCommand() {
Deno.test( 'command subCommand', async () => {

const stats: any = {};
const cmd: Command = command( stats );
Expand All @@ -36,7 +36,7 @@ Deno.test( async function command_subCommand() {
assertEquals( stats.action3, undefined );
} );

Deno.test( async function command_subCommand2() {
Deno.test( 'command subCommand2', async () => {

const stats: any = {};
const cmd: Command = command( stats );
Expand All @@ -50,7 +50,7 @@ Deno.test( async function command_subCommand2() {
assertEquals( stats.action3, undefined );
} );

Deno.test( async function command_subCommand3() {
Deno.test( 'command subCommand3', async () => {

const stats: any = {};
const cmd: Command = command( stats );
Expand All @@ -64,21 +64,21 @@ Deno.test( async function command_subCommand3() {
assertEquals( stats.action3, true );
} );

Deno.test( async function command_subCommand_typeString_flagMissing() {
Deno.test( 'command subCommand typeString flagMissing', async () => {

await assertThrowsAsync( async () => {
await command().parse( [ 'sub-command', 'input-path' ] );
}, Error, 'Missing argument: output' );
} );

Deno.test( async function command_subCommand2_typeString_flagMissing() {
Deno.test( 'command subCommand2 typeString flagMissing', async () => {

await assertThrowsAsync( async () => {
await command().parse( [ 'sub-command2', 'input-path' ] );
}, Error, 'Missing argument: output' );
} );

Deno.test( async function command_subCommand3_typeString_flagMissing() {
Deno.test( 'command subCommand3 typeString flagMissing', async () => {

await assertThrowsAsync( async () => {
await command().parse( [ 'sub-command2', 'sub-command3', 'input-path' ] );
Expand Down
2 changes: 1 addition & 1 deletion packages/command/test/lib/assert.ts
Expand Up @@ -4,4 +4,4 @@ export {
assertStrictEq,
assertThrows,
assertThrowsAsync
} from 'https://deno.land/std@v0.41.0/testing/asserts.ts';
} from 'https://deno.land/std@v0.42.0/testing/asserts.ts';
2 changes: 1 addition & 1 deletion packages/command/test/option/action_test.ts
@@ -1,7 +1,7 @@
import { Command } from '../../lib/command.ts';
import { assertEquals } from '../lib/assert.ts';

Deno.test( async function command_optionAction_action() {
Deno.test( 'command optionAction action', async () => {

let actionOptions!: any;
let actionArgs!: string[];
Expand Down
16 changes: 8 additions & 8 deletions packages/command/test/option/aliases_test.ts
Expand Up @@ -6,60 +6,60 @@ const cmd = new Command()
.option( '-f, --flag, --fl, --flags [value:boolean]', 'description ...' )
.action( () => {} );

Deno.test( async function command_optionAliases_f() {
Deno.test( 'command optionAliases f', async () => {

const { options, args } = await cmd.parse( [ '-f' ] );

assertEquals( options, { flag: true } );
assertEquals( args, [] );
} );

Deno.test( async function command_optionAliases_fl() {
Deno.test( 'command optionAliases fl', async () => {

const { options, args } = await cmd.parse( [ '--fl' ] );

assertEquals( options, { flag: true } );
assertEquals( args, [] );
} );

Deno.test( async function command_optionAliases_flag() {
Deno.test( 'command optionAliases flag', async () => {

const { options, args } = await cmd.parse( [ '--flag' ] );

assertEquals( options, { flag: true } );
assertEquals( args, [] );
} );

Deno.test( async function command_optionAliases_flags() {
Deno.test( 'command optionAliases flags', async () => {

const { options, args } = await cmd.parse( [ '--flags' ] );

assertEquals( options, { flag: true } );
assertEquals( args, [] );
} );

Deno.test( async function command_optionAliases_fInvalidValie() {
Deno.test( 'command optionAliases fInvalidValie', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '-f', 'value' ] );
}, Error, 'Option --flag must be of type boolean but got: value' );
} );

Deno.test( async function command_optionAliases_flInvalidValue() {
Deno.test( 'command optionAliases flInvalidValue', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '--fl', 'value' ] );
}, Error, 'Option --flag must be of type boolean but got: value' );
} );

Deno.test( async function command_optionAliases_flagInvalidValue() {
Deno.test( 'command optionAliases flagInvalidValue', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '--flag', 'value' ] );
}, Error, 'Option --flag must be of type boolean but got: value' );
} );

Deno.test( async function command_optionAliases_flagsInvalidValue() {
Deno.test( 'command optionAliases flagsInvalidValue', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '--flags', 'value' ] );
Expand Down
8 changes: 4 additions & 4 deletions packages/command/test/option/conflicts_test.ts
Expand Up @@ -25,30 +25,30 @@ const cmd = new Command()
} )
.action( () => {} );

Deno.test( async function command_optionConflicts_noArguments() {
Deno.test( 'command optionConflicts noArguments', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [] );
}, Error, 'Missing required option: --type' );
} );

Deno.test( async function command_optionConflicts_type() {
Deno.test( 'command optionConflicts type', async () => {

const { options, args } = await cmd.parse( [ '-t', 'value' ] );

assertEquals( options, { type: 'value' } );
assertEquals( args, [] );
} );

Deno.test( async function command_optionConflicts_videoAudioImageType() {
Deno.test( 'command optionConflicts videoAudioImageType', async () => {

const { options, args } = await cmd.parse( [ '-v', 'value', '-a', 'value', '--image-type', 'value' ] );

assertEquals( options, { videoType: 'value', audioType: 'value', imageType: 'value' } );
assertEquals( args, [] );
} );

Deno.test( async function command_optionConflicts_videoAudioImageType() {
Deno.test( 'command optionConflicts videoAudioImageType', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '-v', 'value', '-a', 'value' ] );
Expand Down
10 changes: 5 additions & 5 deletions packages/command/test/option/duplicate_test.ts
Expand Up @@ -6,35 +6,35 @@ const cmd = new Command()
.option( '-f, --flag [value:boolean]', 'description ...' )
.action( () => {} );

Deno.test( async function command_optionDuplicate_flag() {
Deno.test( 'command optionDuplicate flag', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '-f', '-f', 'unknown' ] );
}, Error, 'Duplicate option: -f' );
} );

Deno.test( async function command_optionDuplicate_flagLong() {
Deno.test( 'command optionDuplicate flagLong', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '-f', '--flag' ] );
}, Error, 'Duplicate option: --flag' );
} );

Deno.test( async function command_optionDuplicate_flagTrueLongFalse() {
Deno.test( 'command optionDuplicate flagTrueLongFalse', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '-f', 'true', '--flag', 'false' ] );
}, Error, 'Duplicate option: --flag' );
} );

Deno.test( async function command_optionDuplicate_flagTrueNoFlag() {
Deno.test( 'command optionDuplicate flagTrueNoFlag', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '-f', 'true', '--no-flag' ] );
}, Error, 'Duplicate option: --no-flag' );
} );

Deno.test( async function command_optionDuplicate_flagTrueNoFlagTrue() {
Deno.test( 'command optionDuplicate flagTrueNoFlagTrue', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [ '-f', 'true', '--no-flag', 'true' ] );
Expand Down
4 changes: 2 additions & 2 deletions packages/command/test/option/required_test.ts
Expand Up @@ -7,15 +7,15 @@ const cmd = new Command()
.option( '-f, --flag [value:string]', 'description ...', { required: true } )
.action( () => {} );

Deno.test( async function command_optionRequired() {
Deno.test( 'command optionRequired', async () => {

const { options, args } = await cmd.parse( [ '-f', 'value' ] );

assertEquals( options, { flag: 'value' } );
assertEquals( args, [] );
} );

Deno.test( async function command_optionRequired_noArguments() {
Deno.test( 'command optionRequired noArguments', async () => {

await assertThrowsAsync( async () => {
await cmd.parse( [] );
Expand Down

0 comments on commit cddb7d1

Please sign in to comment.