Skip to content

Commit 121fe06

Browse files
committed
Add directory only output option
1 parent 0ce8e51 commit 121fe06

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# struct cli
2-
`struct` is a tool for generating trees from a user's file system as well as building structures in the file system from an exisiting tree
2+
`struct` is a tool for generating trees from a user's file system as well as building structures in the file system from an existing tree
33

44
Install it with:
55
```
66
npm i -g @structure-codes/cli
77
```
88

9-
### Configuation
10-
By default, the cli will ignore certain directories which you are unlikely to want to include in tree output. This configuration will be stored in `.treerc` in your home directory (determined by either $HOME or $USERPROFILE). By default, the below directories are ignored:
9+
### Configuration
10+
By default, the cli will ignore certain directories which you are unlikely to want to include in tree output. This configuration will be stored in `.treerc` in your home directory (determined by either `$HOME` or `$USERPROFILE`). By default, the below directories are ignored:
1111
```
1212
.git
1313
node_modules
1414
```
1515
If a `.treerc` file is not found when running the tool, you will be prompted to create one.
1616
### Generating structure from a directory
17-
Running `struct` will output a tree of you current directory by default. You can also specify a path to a target directory and different output options.
17+
Running `struct` will output a tree from your current directory by default. You can also specify a path to a target directory and different output options.
1818
```
1919
Usage: struct [options] [command] [directory]
2020

src/generateTree.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ const globOptions = ({ parentDir, ignored, configIgnore }) => {
2525

2626
export const generateTree = (directory: string, options) => {
2727
if (!validatePath(directory, "dir")) return;
28-
const { silent, json, outputFile, editor, ignore: ignored, configIgnore } = options;
28+
const { silent, json, outputFile, editor, ignore: ignored, configIgnore, dirOnly } = options;
2929
const absolutePath = path.resolve(directory).replace(/\\/g, "/");
30-
30+
const searchPath = `${absolutePath}/**/*${dirOnly ? "/" : ""}`;
3131
glob(
32-
absolutePath + "/**/*",
32+
searchPath,
3333
globOptions({ parentDir: absolutePath, ignored, configIgnore }),
3434
(err, matches) => {
3535
if (err) {

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { checkConfig } from "./checkConfig";
3030
// .option("-d, --depth <depth>", "depth to search within the target directory")
3131
.option("-i, --ignore <ignore>", "ignore these patterns", collect, [])
3232
.option("-c, --config-ignore", "include patterns that are ignored by config")
33+
.option("-d, --dir-only", "ignore files in tree output")
3334
.option("-j, --json", "print tree in json format")
3435
.option("-e, --editor", "open structure in new vscode window")
3536
.option("-s, --silent", "do not print anything to the console")

0 commit comments

Comments
 (0)