@ssebastien/tcmd 0.1.2 → 0.1.4
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.
- package/README.md +121 -38
- package/bin/tcmd +11 -3
- package/bin/tcmd.js +15 -0
- package/package.json +4 -3
- package/public/index.html +14 -0
- package/public/main.js +17501 -0
- package/public/style.css +901 -0
- package/scripts/serve-web.js +61 -0
- package/src/js/tcmd/components/App.html +28 -12
- package/src/js/tcmd/components/App.js +135 -85
- package/src/js/tcmd/components/App.xml +64 -15
- package/src/js/tcmd/components/BookmarkList.html +3 -2
- package/src/js/tcmd/components/BookmarkList.js +1 -1
- package/src/js/tcmd/components/Breadcrumbs.js +1 -1
- package/src/js/tcmd/components/CommandArgRow.html +17 -0
- package/src/js/tcmd/components/CommandArgRow.js +86 -26
- package/src/js/tcmd/components/CommandArgRow.xml +31 -4
- package/src/js/tcmd/components/CommandBar.html +1 -1
- package/src/js/tcmd/components/CommandBar.js +3 -3
- package/src/js/tcmd/components/CommandItem.html +1 -1
- package/src/js/tcmd/components/CommandItem.js +1 -0
- package/src/js/tcmd/components/CommandPanel.html +29 -0
- package/src/js/tcmd/components/CommandPanel.js +54 -52
- package/src/js/tcmd/components/CommandPanel.xml +38 -24
- package/src/js/tcmd/components/Confirm.html +1 -1
- package/src/js/tcmd/components/EntryDetail.html +7 -7
- package/src/js/tcmd/components/EntryDetail.js +1 -1
- package/src/js/tcmd/components/FileList.html +5 -1
- package/src/js/tcmd/components/FileList.js +2 -1
- package/src/js/tcmd/components/FilePreview.html +14 -3
- package/src/js/tcmd/components/FilePreview.js +73 -10
- package/src/js/tcmd/components/FilePreview.xml +19 -6
- package/src/js/tcmd/components/FileRow.html +1 -1
- package/src/js/tcmd/components/FileRow.js +10 -3
- package/src/js/tcmd/components/FilterBar.html +1 -1
- package/src/js/tcmd/components/FilterBar.js +14 -4
- package/src/js/tcmd/components/FilterBar.xml +1 -1
- package/src/js/tcmd/{tui/frame.js → components/Frame.js} +120 -91
- package/src/js/tcmd/components/Help.html +7 -0
- package/src/js/tcmd/components/Help.js +109 -0
- package/src/js/tcmd/components/Summary.html +1 -1
- package/src/js/tcmd/components/Summary.js +1 -6
- package/src/js/tcmd/components/icons.js +39 -5
- package/src/js/tcmd/components/index.js +3 -4
- package/src/js/tcmd/components/rows.js +37 -33
- package/src/js/tcmd/core/commands.js +422 -180
- package/src/js/tcmd/core/directory.js +145 -95
- package/src/js/tcmd/core/fs.js +29 -2
- package/src/js/tcmd/core/history.js +58 -0
- package/src/js/tcmd/core/index.js +3 -9
- package/src/js/tcmd/core/keymap.js +3 -3
- package/src/js/tcmd/core/operations.js +108 -15
- package/src/js/tcmd/core/pane.js +31 -8
- package/src/js/tcmd/core/panel.js +172 -82
- package/src/js/tcmd/core/script.js +7 -95
- package/src/js/tcmd/core/selection.js +9 -1
- package/src/js/tcmd/core/session.js +280 -152
- package/src/js/tcmd/index.js +0 -1
- package/src/js/tcmd/tui/app.js +26 -5
- package/src/js/tcmd/tui/catalogue.js +6 -19
- package/src/js/tcmd/tui/index.js +1 -16
- package/src/js/tcmd/tui/theme.js +5 -0
- package/src/js/tcmd/web/app.js +158 -32
- package/src/js/tcmd/web/bookmarks.js +36 -0
- package/src/js/tcmd/web/catalogue.js +45 -39
- package/src/js/tcmd/web/effects.js +143 -0
- package/src/js/tcmd/web/header.html +1 -1
- package/src/js/tcmd/web/header.js +15 -11
- package/src/js/tcmd/web/main.js +6 -66
- package/src/js/tcmd/web/seed.js +3 -3
- package/src/js/tcmd/web/server.js +6 -4
- package/src/js/tcmd/web/theme.js +1 -0
- package/src/js/tcmd/components/CommandPalette.html +0 -7
- package/src/js/tcmd/components/CommandPalette.js +0 -58
- package/src/js/tcmd/components/CommandPalette.xml +0 -16
- package/src/js/tcmd/components/PaletteRow.html +0 -3
- package/src/js/tcmd/components/PaletteRow.js +0 -43
- package/src/js/tcmd/components/PaletteRow.xml +0 -4
- package/src/js/tcmd/tui/help.js +0 -32
package/README.md
CHANGED
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
TinyCommand `tcmd` is a midnight-commander-like CLI and desktop tool:
|
|
12
12
|
|
|
13
|
-
- Browse files in
|
|
14
|
-
|
|
13
|
+
- Browse files in the three-column explorer (the opening view) — the parent
|
|
14
|
+
directory, the current directory (slightly wider) and the preview — or in
|
|
15
|
+
the two-pane commander (the left is the source, the right the destination),
|
|
16
|
+
with `t` toggling between the two views. Clicking any column, preview
|
|
17
|
+
included, gives it the focus.
|
|
15
18
|
- Named bookmarks: `b` records the cursor entry (or the pane directory) under
|
|
16
19
|
a name defaulting to its basename, remembering whether it is a file or a
|
|
17
20
|
directory; `g` opens a fzf-style picker over bookmark names and paths. A
|
|
@@ -19,9 +22,27 @@ TinyCommand `tcmd` is a midnight-commander-like CLI and desktop tool:
|
|
|
19
22
|
and previewed in its directory.
|
|
20
23
|
- Operations over the current panes: copy, move, delete/erase, stat, touch,
|
|
21
24
|
selection buffers, edit/view/open and shell commands
|
|
22
|
-
- Command
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
- Command panel (`:`), the one entry point, a two-pane palette: the left pane
|
|
26
|
+
filters (`:xxx`) over the CLI operations (copy, move, rename, delete… — the
|
|
27
|
+
internal TinyCmd actions live on their own keys, not the panel). The right
|
|
28
|
+
pane lists the selected command's arguments under its name — each row an
|
|
29
|
+
aligned label and its value in a boxed field (a text field to fill in), or a
|
|
30
|
+
checkbox (multiple) / radio (single) list of the selected paths wrapped in its
|
|
31
|
+
own border, with a lone path shown read-only — and the resolved command at its
|
|
32
|
+
foot. `Tab` cycles the filter and the argument rows; `Enter` runs a complete
|
|
33
|
+
command or jumps to the next missing argument. `!` lands straight on the shell
|
|
34
|
+
command. A destination/path argument browses the filesystem in a file picker
|
|
35
|
+
(`⌃O`): explorer mode has no destination pane, so a move or copy there asks
|
|
36
|
+
where to. A `rename` operation replaces a literal `FIND` with `REPLACE` across
|
|
37
|
+
the selection — one file replaces its whole name — previewing each
|
|
38
|
+
`old → new` before it runs.
|
|
39
|
+
- Keyboard and mouse navigation, inline file previews — a previewed directory
|
|
40
|
+
renders as a pane (its breadcrumbs over its own listing), in both views
|
|
41
|
+
- Symlinks are shown *and* followed: a link row prints `name -> target`
|
|
42
|
+
(`notes.md -> notes.txt`, `docs/ -> ../shared`), a link to a directory is a
|
|
43
|
+
directory (it sorts, opens and previews as one), and the preview reads
|
|
44
|
+
through it — the header reads `notes.md -> notes.txt <TXT>` and the kind
|
|
45
|
+
comes from the target's extension, not the link's name
|
|
25
46
|
- Bookmarks and quick find (later milestones)
|
|
26
47
|
|
|
27
48
|
References: [Marta.sh](https://marta.sh) for the UI, [fman.io](https://fman.io)
|
|
@@ -46,23 +67,29 @@ bun run tcmd # open cwd (left) and ~ (right)
|
|
|
46
67
|
bun run tcmd /tmp ~ # open specific directories
|
|
47
68
|
```
|
|
48
69
|
|
|
49
|
-
Keys: `↑/↓` move (`^↑/^↓` jump a few lines), `Enter/→` open
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
Keys: `↑/↓` move (`^↑/^↓` jump a few lines), `Enter/→` open (re-entering a
|
|
71
|
+
directory restores the cursor it was left with), `←/Bksp` parent (the cursor
|
|
72
|
+
lands on the directory you left), `Esc`/`⇧Esc` history back/forward, `Tab`/`⇧Tab` switch panes
|
|
73
|
+
(`⇧Tab` goes back), `t` toggle the commander/explorer view, `Space` mark, `b`
|
|
74
|
+
bookmark the cursor entry (or the pane
|
|
75
|
+
directory) under a basename-defaulted name, `g` jump to a bookmark, `:` open the
|
|
76
|
+
command panel (the one entry point: CLI operations and TinyCmd actions, their
|
|
77
|
+
arguments, the live resolved command, and the inline file picker on `⌃O`), `v` preview (fullscreen viewer when
|
|
78
|
+
the terminal is narrow), `⇧V` maximize the preview over the columns and back
|
|
79
|
+
again, `O`/`E` open/edit the previewed file, `/` fuzzy-filter
|
|
80
|
+
the active pane (`Enter` keeps it, `Esc` clears), `!` open the panel on the
|
|
81
|
+
shell command, `^R` reload, `?` key reference, `q` quit.
|
|
82
|
+
|
|
83
|
+
The workspace opens in explorer mode with a slim identity bar (`TinyCmd -
|
|
84
|
+
HOST`) — the view mode and version trailing at its right, the mode word drawn
|
|
85
|
+
letter by letter along the logo's own gradients (`explorer` in the Tiny blues,
|
|
86
|
+
`commander` in the Cmd oranges) and the version dim after it — over an
|
|
87
|
+
unframed tiling of pane boxes (the two middle edges sit side by side) labelled
|
|
88
|
+
**SRC** (left, source) / **DST** (right, destination) in commander, with a
|
|
62
89
|
header row (label + clickable breadcrumbs — collapsed to first letters like
|
|
63
90
|
`/h/s/W/Perso/tcmd` when the width demands — + the inline filter) separated by a
|
|
64
91
|
rule from the listing, an entry-detail line for the selected entry, and one
|
|
65
|
-
summary row, so the
|
|
92
|
+
summary row, so the columns stay aligned. The detail line shows
|
|
66
93
|
`date · type · size · rights` with the rights right-aligned, the date and size
|
|
67
94
|
bright, and the size/rights dropping out when the pane is too narrow; the
|
|
68
95
|
summary row is indented to match. The active pane's border and header
|
|
@@ -70,15 +97,44 @@ rule are highlighted and its cursor row uses the strong cursor colour, while
|
|
|
70
97
|
the inactive pane stays dim with a muted cursor. Rows lead with a yazi-style
|
|
71
98
|
Nerd Font icon (folder/link kind icons plus a per-extension icon, `Makefile`,
|
|
72
99
|
`Dockerfile` and dotfiles included), on unless `TCMD_ICONS=0` — it needs a
|
|
73
|
-
Nerd-Font-patched terminal font, and the web view never shows icons.
|
|
100
|
+
Nerd-Font-patched terminal font, and the web view never shows icons. The
|
|
101
|
+
command panel marks its entries the same way — a glyph in the TUI, a `cli`/`app`
|
|
102
|
+
tag on the web. A
|
|
74
103
|
context-aware inspector sits
|
|
75
104
|
on the right when the terminal is at least 100 columns wide, and becomes a
|
|
76
|
-
fullscreen viewer below that
|
|
105
|
+
fullscreen viewer below that; `⇧V` expands it over the whole pane row —
|
|
106
|
+
parent and current included — and brings the previous layout back on the next
|
|
107
|
+
press. The status bar lists every binding as a bracket
|
|
77
108
|
shorthand (`[Open ⏎]`) wrapping over as many rows as the width demands — the
|
|
78
109
|
marked count trails the list, and a notice or error swaps the keys for a
|
|
79
110
|
one-line status. Below 64×16
|
|
80
111
|
the app shows a resize hint instead of the workspace.
|
|
81
112
|
|
|
113
|
+
### View modes
|
|
114
|
+
|
|
115
|
+
`t` flips the workspace between two modes:
|
|
116
|
+
|
|
117
|
+
- **explorer** (the default) leads with the parent of the current directory,
|
|
118
|
+
so the three columns read parent · current · preview — a Miller chain with
|
|
119
|
+
the current column slightly wider than its neighbours;
|
|
120
|
+
- **commander** tiles source and destination.
|
|
121
|
+
|
|
122
|
+
The parent and preview columns are mirrors: they own their cursor, filter and
|
|
123
|
+
marks, but opening an entry, stepping up, following one of their breadcrumbs or
|
|
124
|
+
clicking one of their rows moves the pane they follow, which is what keeps the
|
|
125
|
+
mirror in step (in the explorer the previewed directory *is* the current
|
|
126
|
+
column's own child, so the chain never drifts). A click on the parent column
|
|
127
|
+
makes the clicked directory the current one — or, for a file, opens its
|
|
128
|
+
directory with the file selected and previewed — while a click inside the
|
|
129
|
+
previewed directory promotes that directory to current with the clicked entry
|
|
130
|
+
selected (focus stays on the column that was clicked). The parent mirror's
|
|
131
|
+
cursor also follows the current
|
|
132
|
+
directory: it lands on the entry the current pane shows, so the chain always
|
|
133
|
+
highlights where it is. `Tab` cycles through the columns the current mode shows,
|
|
134
|
+
and clicking any column — the preview included — gives it the focus. A
|
|
135
|
+
previewed directory always renders as a pane, in both modes: its breadcrumbs
|
|
136
|
+
over its own listing, instead of a directory card.
|
|
137
|
+
|
|
82
138
|
### Web version
|
|
83
139
|
|
|
84
140
|
The web view runs the same core on select.js and offers two filesystem
|
|
@@ -89,21 +145,42 @@ backends:
|
|
|
89
145
|
- **HTTP API** (automatic fallback, or `?fs=http`): the server exposes the
|
|
90
146
|
real filesystem over `/api/*`, using the same Node adapter as the TUI.
|
|
91
147
|
|
|
148
|
+
It uses the same command panel (`:`), selection/filter and history keys as the
|
|
149
|
+
TUI, plus `?` for the key reference. Pane focus, marks,
|
|
150
|
+
entry details and command risk colours follow the terminal presentation. The
|
|
151
|
+
inspector sits beside the panes when wide and opens with `v` as a fullscreen
|
|
152
|
+
viewer when narrow (`Esc` closes it); `⇧V` maximizes it over the pane row and
|
|
153
|
+
restores the layout. Bookmarks persist in browser storage,
|
|
154
|
+
separately for each filesystem backend and HTTP root; they are not shared with
|
|
155
|
+
the TUI's bookmark file. Storage denial leaves bookmarks usable for the session.
|
|
156
|
+
|
|
92
157
|
```sh
|
|
158
|
+
tcmd --server # installed command: serve the web UI without the TUI
|
|
93
159
|
make run-local # build and serve both backends (alias to `bun run web`)
|
|
94
160
|
bun run web # build and serve both backends on http://localhost:8787
|
|
95
161
|
bun run web:build # bundle only, into public/main.js
|
|
96
162
|
bun run web:serve # serve the existing bundle plus /api/*
|
|
97
163
|
```
|
|
98
164
|
|
|
165
|
+
From a checkout, `./bin/tcmd --server` (or `bun run tcmd --server`) does the
|
|
166
|
+
same thing, building the browser bundle if it is missing. Installed packages
|
|
167
|
+
include the bundle. Open http://localhost:8787/?fs=http for your actual files,
|
|
168
|
+
or http://localhost:8787/?fs=opfs for the browser-storage demo. Stop with Ctrl-C.
|
|
169
|
+
Use `HOST=0.0.0.0 PORT=9000 tcmd --server` to change the address and port
|
|
170
|
+
(default `127.0.0.1:8787`), or
|
|
171
|
+
`TCMD_WEB_ROOT=/some/dir tcmd --server` to confine the filesystem API. `HOST`
|
|
172
|
+
takes an IP address (`0.0.0.0` or `::` for every interface); a machine name
|
|
173
|
+
resolves to several addresses and the server binds only one of them.
|
|
174
|
+
|
|
99
175
|
`make run-local` is the local dev entry point (it wraps `bun run web` and
|
|
100
176
|
honours `TCMD_WEB_PORT`, default 8787). The Makefile bootstraps the LittleSDK
|
|
101
177
|
into `deps/sdk` for the standard `make` targets.
|
|
102
178
|
|
|
103
179
|
Appending `?fs=opfs` or `?fs=http` to the URL forces one backend. The HTTP
|
|
104
180
|
backend needs the page served by `bun run web:serve` (a plain static server
|
|
105
|
-
only supports OPFS); the server binds to loopback
|
|
106
|
-
token injected into `index.html`.
|
|
181
|
+
only supports OPFS); the server binds to loopback by default (`HOST`
|
|
182
|
+
overrides it) and requires a per-process token injected into `index.html`.
|
|
183
|
+
`TCMD_WEB_ROOT=/some/dir` confines the API
|
|
107
184
|
(default `/`, the same access as `bun run tcmd`), but it is not a sandbox:
|
|
108
185
|
don't expose the port. With OPFS, deleting moves entries to `/.trash`; the API
|
|
109
186
|
uses the desktop trash. Open/edit/run are unavailable in the browser either
|
|
@@ -125,26 +202,26 @@ src/js/tcmd/
|
|
|
125
202
|
entries.js filter/sort over file entries (dirs first)
|
|
126
203
|
selection.js cursor/mark arithmetic
|
|
127
204
|
directory.js one pane's directory: path, entries, view, cursor, marks
|
|
128
|
-
pane.js one directory, proxying its cells
|
|
205
|
+
pane.js one directory, proxying its cells + currentPane resolution
|
|
129
206
|
bookmarks.js named bookmarks (path + file/dir kind) + the memory/file stores
|
|
130
|
-
panel.js command panel:
|
|
131
|
-
session.js two panes + active pane, preview,
|
|
207
|
+
panel.js command panel: CLI ops + TinyCmd actions, args bound from context
|
|
208
|
+
session.js two panes + parent/preview mirrors, view mode, active pane, preview, panel, dispatch
|
|
132
209
|
keymap.js key chords -> command ids
|
|
133
210
|
commands.js command registry; commands are `run(session, payload)`
|
|
134
|
-
operations.js
|
|
135
|
-
script.js scripting line parser
|
|
211
|
+
operations.js CLI operations (copy/move/delete/erase/stat/sel/…)
|
|
212
|
+
script.js scripting line parser and runner
|
|
136
213
|
components/ Shared, renderer-agnostic component logic
|
|
137
214
|
App.js root controller: key + event -> dispatch
|
|
138
215
|
bind.js `ui.component(name).does(behaviors).using(source)` binding
|
|
139
216
|
rows.js keyed row-bag builders shared by both catalogues
|
|
140
217
|
FileList.js … one `.js` per component (behaviors + pure helpers)
|
|
141
218
|
FileRow.js … row behaviors shared by both engines
|
|
219
|
+
Frame.js workspace chrome, breakpoints and command-bar geometry
|
|
220
|
+
Help.js key-reference overlay behaviors + the grouped key text
|
|
142
221
|
format.js presentation helpers (sizes/counts)
|
|
143
222
|
tui/ View (select.tui templates on OpenTUI)
|
|
144
223
|
app.js binds App.js + App.xml + TUI environment; size/help cells
|
|
145
224
|
catalogue.js binds each `components/*.js` to its `.xml` and registers tags
|
|
146
|
-
frame.js TUI-only chrome: frame title, breakpoints
|
|
147
|
-
help.js TUI-only `?` key-reference overlay behaviors
|
|
148
225
|
index.js TUI entry point; feeds `size` from renderer resize events
|
|
149
226
|
theme.js TUI palette resolver (dark/light/mono, NO_COLOR)
|
|
150
227
|
web/ Browser view (select.js templates on the DOM, same core)
|
|
@@ -152,6 +229,8 @@ src/js/tcmd/
|
|
|
152
229
|
catalogue.js binds each `components/*.js` to its `.html`
|
|
153
230
|
index.js web entry point: `main(session, selector)`
|
|
154
231
|
main.js browser bootstrap: backend choice + session (bundled)
|
|
232
|
+
effects.js instance-owned focus, key trapping, resize and scroll effects
|
|
233
|
+
bookmarks.js localStorage bookmark store, scoped by backend and API root
|
|
155
234
|
opfs.js OPFS filesystem adapter (browser storage)
|
|
156
235
|
http.js filesystem adapter over the `/api` JSON endpoints
|
|
157
236
|
server.js dev server: `public/` + `/api/*` (used by `bun run web:serve`)
|
|
@@ -177,9 +256,12 @@ reactive collections, sharing row behaviors over a `{ item, index, … }` bag
|
|
|
177
256
|
built by `components/rows.js`; cells stay in the bag and are read at the point
|
|
178
257
|
of use.
|
|
179
258
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
259
|
+
`components/Frame.js` holds the renderer-free workspace chrome (brand bar,
|
|
260
|
+
responsive breakpoints, pane borders, command-bar geometry) and
|
|
261
|
+
`components/Help.js` holds the key reference — behaviours and the grouped key
|
|
262
|
+
text — used by both views. Web-only components live under `web/` (`header.js` +
|
|
263
|
+
`header.html`, plus the DOM effects in `effects.js` and the bookmark store in
|
|
264
|
+
`bookmarks.js`). Shared
|
|
183
265
|
behaviors only ever grow additively (a new key for a new presentation),
|
|
184
266
|
so the other engine's presentation and the parity tests keep working unchanged.
|
|
185
267
|
|
|
@@ -222,11 +304,12 @@ tests run the shared logic through select.js on a happy-dom document.
|
|
|
222
304
|
## Roadmap
|
|
223
305
|
|
|
224
306
|
- [x] Walking skeleton: two panes, navigation, breadcrumbs, summary, command
|
|
225
|
-
bar, command
|
|
226
|
-
- [x] File operations (copy/move/delete/erase/stat/touch/sel),
|
|
227
|
-
|
|
228
|
-
- [x]
|
|
229
|
-
|
|
307
|
+
bar, command panel, text preview
|
|
308
|
+
- [x] File operations (copy/move/delete/erase/stat/touch/sel), with the
|
|
309
|
+
`$A`/`$B` pane filesets and `$FILE` still resolving in any argument
|
|
310
|
+
- [x] Unified command panel (`:`): the CLI operations and the TinyCmd actions in
|
|
311
|
+
one filtered list, each marked by its namespace, with editable arguments
|
|
312
|
+
and a resolved-command preview; `!` lands on the shell command
|
|
230
313
|
- [x] Pane fuzzy filtering (`/` to filter, `Enter` to keep, `Esc` to clear)
|
|
231
314
|
- [x] Named bookmarks (`b` records, `g` jumps, persisted to a JSON file)
|
|
232
315
|
- [ ] Quick find, grep
|
package/bin/tcmd
CHANGED
|
@@ -5,13 +5,21 @@ if ! command -v bun >/dev/null 2>&1; then
|
|
|
5
5
|
exit 1
|
|
6
6
|
fi
|
|
7
7
|
script=$0
|
|
8
|
+
case "$script" in
|
|
9
|
+
*/*) ;;
|
|
10
|
+
*) script=$(command -v "$script") ;;
|
|
11
|
+
esac
|
|
12
|
+
case "$script" in
|
|
13
|
+
/*) ;;
|
|
14
|
+
*) script=$PWD/$script ;;
|
|
15
|
+
esac
|
|
8
16
|
while [ -L "$script" ]; do
|
|
9
|
-
dir=$(CDPATH= cd -- "$(dirname -- "$script")" && pwd)
|
|
17
|
+
dir=$(CDPATH= cd -P -- "$(dirname -- "$script")" && pwd)
|
|
10
18
|
link=$(readlink "$script")
|
|
11
19
|
case "$link" in
|
|
12
20
|
/*) script=$link ;;
|
|
13
21
|
*) script=$dir/$link ;;
|
|
14
22
|
esac
|
|
15
23
|
done
|
|
16
|
-
dir=$(CDPATH= cd -- "$(dirname -- "$script")" && pwd)
|
|
17
|
-
exec bun "$dir
|
|
24
|
+
dir=$(CDPATH= cd -P -- "$(dirname -- "$script")" && pwd)
|
|
25
|
+
exec bun "$dir/tcmd.js" "$@"
|
package/bin/tcmd.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// TinyCommand `tcmd` entry point.
|
|
3
|
+
const raw = process.argv.slice(2).filter((arg) => arg !== "-")
|
|
4
|
+
// `--server` is a mode flag, not a path: accept it in any position.
|
|
5
|
+
const server = raw.includes("--server")
|
|
6
|
+
const paths = raw.filter((arg) => arg !== "--server")
|
|
7
|
+
if (server) {
|
|
8
|
+
if (paths.length > 0) {
|
|
9
|
+
console.error("Usage: tcmd --server (configure with HOST, PORT and TCMD_WEB_ROOT)")
|
|
10
|
+
process.exit(1)
|
|
11
|
+
}
|
|
12
|
+
await import("../scripts/serve-web.js").then((web) => web.main())
|
|
13
|
+
} else {
|
|
14
|
+
await import("../src/js/tcmd/tui/index.js").then((tui) => tui.main(paths))
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssebastien/tcmd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "TinyCommand: a midnight-commander-like CLI and desktop tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/js/tcmd/index.js",
|
|
7
|
-
"files": ["bin/", "src/js/tcmd/", "README.md"],
|
|
7
|
+
"files": ["bin/", "src/js/tcmd/", "scripts/serve-web.js", "public/", "README.md"],
|
|
8
8
|
"bin": {
|
|
9
9
|
"tcmd": "./bin/tcmd"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"test": "bun test tests",
|
|
13
|
-
"tcmd": "bun
|
|
13
|
+
"tcmd": "bun bin/tcmd.js",
|
|
14
|
+
"prepack": "bun run web:build",
|
|
14
15
|
"web": "bun run web:build && bun run web:serve",
|
|
15
16
|
"web:build": "bun build src/js/tcmd/web/main.js --outdir public --target browser",
|
|
16
17
|
"web:serve": "bun scripts/serve-web.js"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="tcmd-token" content="__TCMD_TOKEN__" />
|
|
7
|
+
<title>TinyCommand web</title>
|
|
8
|
+
<link rel="stylesheet" href="./style.css" />
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app"></div>
|
|
12
|
+
<script type="module" src="./main.js"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|