Unverified Commit d98a4df1 authored by Hong Minhee's avatar Hong Minhee
Browse files

Merge pull request #328 from w8385/cli/webfinger/add-max-redirection-option

parents 8990b9c7 9356087c
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -82,6 +82,9 @@ the versioning.
        in the WebFinger request.
     -  The `--allow-private-address` or `-p` option allows looking up
        WebFinger information for private addresses (e.g., `localhost`).
     -  The `--max-redirection` option allows uses to specify the maximum
        number of redirects to follow when performing WebFinger lookups.
        [[#311], [#328] by KeunHyeong Park]

 -  Added `--dry-run` option to `fedify init` command.  This option allows users
    to preview what files and configurations would be created without actually
@@ -118,8 +121,9 @@ the versioning.
[#300]: https://github.com/fedify-dev/fedify/pull/300
[#304]: https://github.com/fedify-dev/fedify/issues/304
[#309]: https://github.com/fedify-dev/fedify/pull/309
[#311]: https://github.com/fedify-dev/fedify/issues/311
[#321]: https://github.com/fedify-dev/fedify/pull/321

[#328]: https://github.com/fedify-dev/fedify/pull/309


Version 1.7.6
+12 −1
Original line number Diff line number Diff line
import { Command } from "@cliffy/command";
import { Command, ValidationError } from "@cliffy/command";
import { toAcctUrl } from "@fedify/fedify/vocab";
import { lookupWebFinger } from "@fedify/fedify/webfinger";
import ora from "ora";
@@ -17,7 +17,18 @@ export const command = new Command()
    "-p, --allow-private-address",
    "Allow private IP addresses in the URL.",
  )
  .option(
    "--max-redirection <maxRedirection:integer>",
    "Maximum number of redirections to follow.",
    { default: 5 },
  )
  .action(async (options, ...resources: string[]) => {
    if (options.maxRedirection < 0) { // Validate maxRedirection option
      throw new ValidationError(
        `Option --max-redirection must be greater than or equal to 0, but got ${options.maxRedirection}.`,
      );
    }

    for (const resource of resources) {
      const spinner = ora({ // Create a spinner for the lookup process
        text: `Looking up WebFinger for ${resource}`,
+18 −1
Original line number Diff line number Diff line
@@ -1183,6 +1183,23 @@ fedify webfinger --allow-private-address @username@localhost

Mostly useful for testing purposes.  *Do not use this in production.*

### `--max-redirection`: Maximum number of redirections

The `--max-redirection` option is used to control the maximum number of
redirections allowed during WebFinger lookups.  By default, it is set to 5.
If you want to set a custom limit, run the below command:

~~~~ sh
# Use default redirection limit (5)
fedify webfinger @user@example.com

# Set custom redirection limit
fedify webfinger @user@example.com --max-redirection 3

# Disable redirections entirely
fedify webfinger @user@example.com --max-redirection 0
~~~~


Shell completions
-----------------