forked from project-chip/matter.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
1,838 additions
and
82 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A matter.js-based command line utility for interacting with Matter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env matter-run | ||
import { main } from "../dist/esm/cli.js"; | ||
await main(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"name": "@matter/cli-tool", | ||
"version": "0.0.0-git", | ||
"description": "Command line tool for interacting with Matter", | ||
"keywords": [ | ||
"iot", | ||
"home automation", | ||
"matter", | ||
"smart device" | ||
], | ||
"license": "Apache-2.0", | ||
"author": "matter.js authors", | ||
"contributors": [ | ||
"Greg Lauckhart <[email protected]>" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/project-chip/matter.js/issues" | ||
}, | ||
"homepage": "https://github.com/project-chip/matter.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/project-chip/matter.js.git" | ||
}, | ||
"scripts": { | ||
"clean": "matter-build clean", | ||
"build": "matter-build", | ||
"build-clean": "matter-build --clean", | ||
"matter": "matter-run bin/matter.js" | ||
}, | ||
"bin": { | ||
"matter": "bin/matter.js" | ||
}, | ||
"imports": { | ||
"#tools": "@matter/tools", | ||
"#general": "@matter/general", | ||
"#model": "@matter/model", | ||
"#types": "@matter/types", | ||
"#protocol": "@matter/protocol", | ||
"#node": "@matter/node", | ||
"#*": "./src/*" | ||
}, | ||
"dependencies": { | ||
"@matter/general": "*", | ||
"@matter/model": "*", | ||
"@matter/node": "*", | ||
"@matter/protocol": "*", | ||
"@matter/tools": "*", | ||
"@matter/types": "*", | ||
"@types/escodegen": "^0.0.10", | ||
"acorn": "^8.12.1", | ||
"ansi-colors": "^4.1.3", | ||
"escodegen": "^2.1.0", | ||
"yargs": "^17.7.2" | ||
}, | ||
"devDependencies": { | ||
"@matter/tools": "*", | ||
"@types/yargs": "^17.0.33" | ||
}, | ||
"files": [ | ||
"dist/**/*", | ||
"src/**/*", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"type": "module", | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @license | ||
* Copyright 2022-2024 Matter.js Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { repl } from "#repl.js"; | ||
import colors from "ansi-colors"; | ||
import { stdout } from "process"; | ||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
|
||
export async function main(argv: string[]) { | ||
colors.enabled = stdout.isTTY; | ||
|
||
await yargs(hideBin(argv)).usage("Interact with the local Matter environment.").strict().argv; | ||
|
||
// TODO - REPL is enough for testing but need proper CLI | ||
|
||
await repl(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @license | ||
* Copyright 2022-2024 Matter.js Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { bin } from "#globals.js"; | ||
import { stdout } from "process"; | ||
import { inspect } from "util"; | ||
|
||
bin.cat = async function (...args: unknown[]) { | ||
const locations = await Promise.all(args.map(arg => this.location.at(`${arg}`))); | ||
for (const location of locations) { | ||
stdout.write(inspect(location.definition, false, 1, stdout.isTTY)); | ||
stdout.write("\n"); | ||
} | ||
}; | ||
|
||
bin.inspect = bin.cat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @license | ||
* Copyright 2022-2024 Matter.js Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { NotADirectoryError, TooManyArgsError } from "#errors.js"; | ||
import { bin } from "#globals.js"; | ||
|
||
bin.cd = async function (path, ...extraArgs: unknown[]) { | ||
if (extraArgs.length) { | ||
throw new TooManyArgsError("cd"); | ||
} | ||
|
||
if (path === undefined) { | ||
path = "/"; | ||
} else { | ||
path = `${path}`; | ||
} | ||
|
||
const location = await this.location.at(path as string); | ||
|
||
if (location.kind !== "directory") { | ||
throw new NotADirectoryError(path); | ||
} | ||
|
||
this.location = location; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @license | ||
* Copyright 2022-2024 Matter.js Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { TooManyArgsError } from "#errors.js"; | ||
import { bin } from "#globals.js"; | ||
import { stdout } from "process"; | ||
|
||
bin.cwd = function (...args: unknown[]) { | ||
if (args.length) { | ||
throw new TooManyArgsError("cwd"); | ||
} | ||
|
||
stdout.write(this.location.path); | ||
stdout.write("\n"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @license | ||
* Copyright 2022-2024 Matter.js Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { bin } from "#globals.js"; | ||
|
||
bin.help = function () { | ||
// TODO - be helpful | ||
process.stdout.write("Help is on the way!\n"); | ||
}; | ||
|
||
bin.man = bin.help; |
Oops, something went wrong.