Skip to content

Commit 590dc74

Browse files
committed
added search by username
1 parent bdf27b1 commit 590dc74

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ No need to install anything, just use `npx` 🕺
1414

1515
## API Reference
1616

17-
There are 3 flags:
17+
There are 4 flags:
18+
19+
- `--live` - `--l` - all spaces that are live now and match the query.
20+
- `--scheduled` - `--s` - all spaces that are scheduled to be run and match the query.
21+
- `--query=""` - `--q=""` - the keyword to query. This can be any text (including mentions and Hashtags).
22+
- `--host=""` - `--h=""` - all spaces that have been shceduled by the given host. This is someones twitter handle. For example `--host="studio_hungry"`
1823

19-
- `--live` - all spaces that are live now and match the query.
20-
- `--scheduled` - all spaces that are scheduled to be run and match the query.
21-
- `--query=""` - the keyword to query. This can be any text (including mentions and Hashtags).
2224

2325
### Show all live spaces with "developer" in the title
2426

@@ -32,6 +34,12 @@ There are 3 flags:
3234
npx tweespaces --scheduled --query="developer"
3335
```
3436

37+
### Show all scheduled spaces from the user "studio_hungry"
38+
39+
```bash
40+
npx tweespaces --host="studio_hungry"
41+
```
42+
3543
## Result
3644

3745
!['A GIF of running a tweespace command. Shows the CLI output'](tweespaces.gif)

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const { clear, debug } = flags;
2121
init({ clear });
2222
input.includes(`help`) && cli.showHelp(0);
2323

24-
if (flags.username) {
25-
await findSpaceByHost({ username: flags.username })
24+
if (flags.host) {
25+
await findSpaceByHost({ username: flags.host })
2626
}
2727

2828
if (flags.live) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tweespaces",
33
"description": "Lookup Twitter spaces by keyword",
4-
"version": "0.0.29",
4+
"version": "0.0.30",
55
"license": "MIT",
66
"bin": {
77
"tws": "index.js"

utils/cli.js

+4
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,24 @@ const flags = {
2626
},
2727
live: {
2828
type: `boolean`,
29+
alias: `l`,
2930
default: false,
3031
desc: `Spaces live now`
3132
},
3233
scheduled: {
3334
type: `boolean`,
35+
alias: `s`,
3436
default: false,
3537
desc: `Spaces scheduled for later`
3638
},
3739
query: {
3840
type: `string`,
41+
alias: `q`,
3942
desc: `Search query`
4043
},
4144
host: {
4245
type: `string`,
46+
alias: `h`,
4347
desc: `The host of the space`
4448
}
4549
};

utils/find-space-by-host.js

+6-16
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ module.exports = async ({ username }) => {
1717
}
1818
);
1919

20-
// console.log(userResponse.data)
21-
2220
const data = userResponse.data.spaces.data;
23-
console.log({ data })
2421
const meta = userResponse.data.spaces.meta;
2522
const includes = userResponse.data.spaces.includes;
2623

@@ -33,14 +30,13 @@ module.exports = async ({ username }) => {
3330
spinner.stop(true);
3431

3532
if (!hasResult) {
36-
return console.log(emoji.get('scream'), ' ', bold('No results found!'));
33+
return console.log(emoji.get('scream'), ' ', bold(`This person hasn't scheduled any Twitter spaces yet.`));
3734
}
3835

3936
const spaceInfo = data.map(
40-
({ participant_count, scheduled_start, title, creator_id }) => {
37+
({ scheduled_start, title, creator_id }) => {
4138
return {
4239
creator_id,
43-
participants: participant_count,
4440
start: scheduled_start,
4541
title
4642
};
@@ -63,19 +59,13 @@ module.exports = async ({ username }) => {
6359
function twitterHandleLink(handle) {
6460
return `https://twitter.com/${handle}`;
6561
}
62+
6663
space.map(({ title, creator, creatorHandle, start, description }) => {
67-
const timingCheck = () => {
68-
if (start === undefined) {
69-
return console.log(
70-
emoji.get('timer_clock'),
71-
' ',
72-
bold('Live now!')
73-
);
74-
}
64+
const scheduledFor = () => {
7565
return console.log(
7666
emoji.get('timer_clock'),
7767
' ',
78-
bold('Time: ', new Date(start).toLocaleTimeString('en-US')),
68+
bold('Sheduled for: ', new Date(start).toLocaleTimeString('en-US')),
7969
dim(italic(' (All times localized)')),
8070
emoji.get('sunglasses')
8171
);
@@ -105,7 +95,7 @@ module.exports = async ({ username }) => {
10595
console.log();
10696
dateCheck();
10797
console.log();
108-
timingCheck();
98+
scheduledFor();
10999
console.log(
110100
green(
111101
bold(

0 commit comments

Comments
 (0)