crypull 1.0.1 → 1.0.2

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/dist/cli.mjs CHANGED
@@ -2,6 +2,7 @@
2
2
  import { Command } from 'commander';
3
3
  import pc from 'picocolors';
4
4
  import * as asciichart from 'asciichart';
5
+ import { intro, select, isCancel, outro, text } from '@clack/prompts';
5
6
 
6
7
  // src/providers/coingecko.ts
7
8
  var CoinGeckoProvider = class {
@@ -652,7 +653,7 @@ var Crypull = class {
652
653
  */
653
654
  async gas() {
654
655
  try {
655
- const res = await fetch(`https://api.etherscan.io/api?module=gastracker&action=gasoracle`);
656
+ const res = await fetch(`https://api.etherscan.io/v2/api?chainid=1&module=gastracker&action=gasoracle`);
656
657
  if (!res.ok) return null;
657
658
  const data = await res.json();
658
659
  if (data.status !== "1") return null;
@@ -700,11 +701,9 @@ var Crypull = class {
700
701
 
701
702
  // src/index.ts
702
703
  var crypull = new Crypull();
703
-
704
- // src/cli.ts
705
704
  var program = new Command();
706
- program.name("crypull").description("A human-friendly CLI to fetch crypto prices and info from multiple providers").version("1.0.0");
707
- program.command("price <query>").description("Get the current price of a cryptocurrency (symbol or contract address)").action(async (query) => {
705
+ program.name("crypull").description("A human-friendly CLI to fetch crypto prices and info from multiple providers").version("1.0.1");
706
+ var handlePrice = async (query) => {
708
707
  console.log(pc.cyan(`
709
708
  Fetching price for ${pc.bold(query)}...`));
710
709
  const data = await crypull.price(query);
@@ -721,8 +720,8 @@ Fetching price for ${pc.bold(query)}...`));
721
720
  console.log(`${pc.gray("Updated:")} ${new Date(data.lastUpdated).toLocaleTimeString()}`);
722
721
  console.log(pc.white(`----------------------------------------
723
722
  `));
724
- });
725
- program.command("info <query>").description("Get detailed info about a cryptocurrency (market cap, volume, FDV, etc.)").action(async (query) => {
723
+ };
724
+ var handleInfo = async (query) => {
726
725
  console.log(pc.cyan(`
727
726
  Fetching detailed info for ${pc.bold(query)}...`));
728
727
  const data = await crypull.info(query);
@@ -809,8 +808,8 @@ Fetching detailed info for ${pc.bold(query)}...`));
809
808
  console.log(`${pc.gray("Updated:")} ${new Date(data.lastUpdated).toLocaleTimeString()}`);
810
809
  console.log(pc.white(`----------------------------------------
811
810
  `));
812
- });
813
- program.command("top").description("Show top 50 cryptocurrencies by market cap").action(async () => {
811
+ };
812
+ var handleTop = async () => {
814
813
  console.log(pc.cyan(`
815
814
  Fetching top 50 cryptocurrencies...`));
816
815
  const results = await crypull.top();
@@ -834,8 +833,8 @@ Fetching top 50 cryptocurrencies...`));
834
833
  });
835
834
  console.log(pc.white(`----------------------------------------
836
835
  `));
837
- });
838
- program.command("search <query>").description("Search for tokens or coins across multiple providers").action(async (query) => {
836
+ };
837
+ var handleSearch = async (query) => {
839
838
  console.log(pc.cyan(`
840
839
  Searching for ${pc.bold(query)}...`));
841
840
  const results = await crypull.search(query);
@@ -858,8 +857,8 @@ Searching for ${pc.bold(query)}...`));
858
857
  });
859
858
  console.log(pc.white(`----------------------------------------
860
859
  `));
861
- });
862
- program.command("trending").description("Show top 10 trending coins/tokens right now").action(async () => {
860
+ };
861
+ var handleTrending = async () => {
863
862
  console.log(pc.cyan(`
864
863
  Fetching top trending coins...`));
865
864
  const results = await crypull.trending();
@@ -883,8 +882,8 @@ Fetching top trending coins...`));
883
882
  });
884
883
  console.log(pc.white(`----------------------------------------
885
884
  `));
886
- });
887
- program.command("market").description("Show global cryptocurrency market overview").action(async () => {
885
+ };
886
+ var handleMarket = async () => {
888
887
  console.log(pc.cyan(`
889
888
  Fetching global market data...`));
890
889
  const data = await crypull.market();
@@ -905,8 +904,8 @@ Fetching global market data...`));
905
904
  console.log(`${pc.gray("Updated:")} ${new Date(data.lastUpdated).toLocaleTimeString()}`);
906
905
  console.log(pc.white(`----------------------------------------
907
906
  `));
908
- });
909
- program.command("sentiment").description("Show current Crypto Fear & Greed Index").action(async () => {
907
+ };
908
+ var handleSentiment = async () => {
910
909
  console.log(pc.cyan(`
911
910
  Fetching Fear & Greed Index...`));
912
911
  const data = await crypull.sentiment();
@@ -929,8 +928,8 @@ Fetching Fear & Greed Index...`));
929
928
  console.log(`${pc.gray("Classification:")} ${color(pc.bold(data.classification))}`);
930
929
  console.log(pc.white(`----------------------------------------
931
930
  `));
932
- });
933
- program.command("gas").description("Show current Ethereum network gas prices").action(async () => {
931
+ };
932
+ var handleGas = async () => {
934
933
  console.log(pc.cyan(`
935
934
  Fetching network gas prices...`));
936
935
  const data = await crypull.gas();
@@ -950,8 +949,8 @@ Fetching network gas prices...`));
950
949
  }
951
950
  console.log(pc.white(`----------------------------------------
952
951
  `));
953
- });
954
- program.command("chart <query>").description("Draw a terminal ASCII chart of historical prices").option("-d, --days <days>", "Number of days to chart", "7").action(async (query, options) => {
952
+ };
953
+ var handleChart = async (query, options) => {
955
954
  const days = parseInt(options.days) || 7;
956
955
  console.log(pc.cyan(`
957
956
  Fetching ${days}-day chart data for ${pc.bold(query)}...`));
@@ -974,7 +973,97 @@ Fetching ${days}-day chart data for ${pc.bold(query)}...`));
974
973
  console.log(pc.white(`
975
974
  ` + asciichart.plot(data.prices, chartConfig) + `
976
975
  `));
977
- });
978
- program.parse(process.argv);
976
+ };
977
+ var handleDonate = () => {
978
+ console.log(pc.cyan(`
979
+ \u{1F496} Support the development of crypull:`));
980
+ console.log(pc.white(`----------------------------------------`));
981
+ console.log(`${pc.yellow("BTC:")} ${pc.white("bc1qj4zt3lva4r68xspayg0p8s4hyg40nhjz8fuhqq")}`);
982
+ console.log(`${pc.blue("EVM (All):")} ${pc.white("0x63a875d0c4Dad8E18B95D844caE6FF915dF0a2BD")}`);
983
+ console.log(`${pc.green("Solana:")} ${pc.white("8J5VvZu6ayQa4XnSAAzx4YX3QsXYyyNrP4Zr7JEx1KFY")}`);
984
+ console.log(`${pc.red("TRX:")} ${pc.white("TPgZSrHUhKdjyMwaGd15utJvsbk85oBbit")}`);
985
+ console.log(pc.white(`----------------------------------------
986
+ `));
987
+ };
988
+ program.command("price <query>").description("Get the current price of a cryptocurrency (symbol or contract address)").action(handlePrice);
989
+ program.command("info <query>").description("Get detailed info about a cryptocurrency (market cap, volume, FDV, etc.)").action(handleInfo);
990
+ program.command("top").description("Show top 50 cryptocurrencies by market cap").action(handleTop);
991
+ program.command("search <query>").description("Search for tokens or coins across multiple providers").action(handleSearch);
992
+ program.command("trending").description("Show top 10 trending coins/tokens right now").action(handleTrending);
993
+ program.command("market").description("Show global cryptocurrency market overview").action(handleMarket);
994
+ program.command("sentiment").description("Show current Crypto Fear & Greed Index").action(handleSentiment);
995
+ program.command("gas").description("Show current Ethereum network gas prices").action(handleGas);
996
+ program.command("chart <query>").description("Draw a terminal ASCII chart of historical prices").option("-d, --days <days>", "Number of days to chart", "7").action(handleChart);
997
+ program.command("donate").description("Show donation addresses to support development").action(handleDonate);
998
+ async function interactiveMode() {
999
+ console.clear();
1000
+ intro(pc.bgCyan(pc.black(" crypull CLI ")));
1001
+ while (true) {
1002
+ const action = await select({
1003
+ message: "What would you like to do?",
1004
+ options: [
1005
+ { value: "price", label: "\u{1F4B0} Get token price" },
1006
+ { value: "info", label: "\u2139\uFE0F Get detailed token info" },
1007
+ { value: "top", label: "\u{1F3C6} Show top 50 cryptocurrencies" },
1008
+ { value: "search", label: "\u{1F50D} Search for a token" },
1009
+ { value: "trending", label: "\u{1F525} Show trending coins" },
1010
+ { value: "market", label: "\u{1F30D} Show global market overview" },
1011
+ { value: "sentiment", label: "\u{1F3AD} Show Fear & Greed Index" },
1012
+ { value: "gas", label: "\u26FD Show ETH gas prices" },
1013
+ { value: "chart", label: "\u{1F4C8} Show historical price chart" },
1014
+ { value: "donate", label: "\u{1F496} Donate / Support" },
1015
+ { value: "exit", label: "\u274C Exit" }
1016
+ ]
1017
+ });
1018
+ if (isCancel(action) || action === "exit") {
1019
+ outro("Goodbye!");
1020
+ process.exit(0);
1021
+ }
1022
+ if (["price", "info", "search", "chart"].includes(action)) {
1023
+ const query = await text({
1024
+ message: "Enter token symbol or contract address:",
1025
+ placeholder: "e.g., btc, ethereum, 0x...",
1026
+ validate: (value) => {
1027
+ if (!value) return "Please enter a valid query.";
1028
+ }
1029
+ });
1030
+ if (isCancel(query)) {
1031
+ outro("Goodbye!");
1032
+ process.exit(0);
1033
+ }
1034
+ if (action === "price") await handlePrice(query);
1035
+ else if (action === "info") await handleInfo(query);
1036
+ else if (action === "search") await handleSearch(query);
1037
+ else if (action === "chart") {
1038
+ const days = await text({
1039
+ message: "Enter number of days for the chart (default 7):",
1040
+ placeholder: "7",
1041
+ defaultValue: "7"
1042
+ });
1043
+ if (isCancel(days)) {
1044
+ outro("Goodbye!");
1045
+ process.exit(0);
1046
+ }
1047
+ await handleChart(query, { days });
1048
+ }
1049
+ } else {
1050
+ if (action === "top") await handleTop();
1051
+ else if (action === "trending") await handleTrending();
1052
+ else if (action === "market") await handleMarket();
1053
+ else if (action === "sentiment") await handleSentiment();
1054
+ else if (action === "gas") await handleGas();
1055
+ else if (action === "donate") handleDonate();
1056
+ }
1057
+ console.log(pc.gray("\n---\n"));
1058
+ }
1059
+ }
1060
+ if (process.argv.length <= 2) {
1061
+ interactiveMode().catch((err) => {
1062
+ console.error(pc.red("An error occurred:"), err);
1063
+ process.exit(1);
1064
+ });
1065
+ } else {
1066
+ program.parse(process.argv);
1067
+ }
979
1068
  //# sourceMappingURL=cli.mjs.map
980
1069
  //# sourceMappingURL=cli.mjs.map