Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to run the CLI import in non-interactive mode #191

Open
CharlesB2 opened this issue Apr 28, 2022 · 4 comments
Open

Ability to run the CLI import in non-interactive mode #191

CharlesB2 opened this issue Apr 28, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@CharlesB2
Copy link

During setup, we run the CLI import tool a lot, and it's very long to answer all questions. There should be a non-interactive mode with CLI arguments, as well as the ability to provide the API key through an environment variable.

@plaindocs
Copy link

👍 to this!

@pacocoursey pacocoursey added the enhancement New feature or request label Aug 15, 2022
@sherwinski
Copy link

Agreed, this would be great to have when wanting to import lots of projects at once

@johnjeffers
Copy link

Folks, PLEASE add this, I'm begging you. I just wasted hours of my day importing github issues, something I should have been able to script.

@johnjeffers
Copy link

For anyone else struggling with this, here's a half-baked solution using expect.

The reason I say it's half-baked is that it's likely not going to be exactly right for your use case, and it certainly isn't what I'd call a well-written script. I have literally never used expect or tcl before today, and I welcome any suggestions for improvement. But hopefully it's enough to give you a starting point for automating importing multiple repos.

#!/usr/bin/expect -f

set force_conservative 0 
if {$force_conservative} {
	set send_slow {1 .1}
	proc send {ignore arg} {
		sleep .1
		exp_send -s -- $arg
	}
}

set repos {
repo-1
repo-2
repo-3
etc...
}

foreach repo $repos {
	puts "processing repo: $repo"
	set timeout -1

	spawn linear-import
	match_max 100000

	expect "*Input your Linear API key (https://linear.app/settings/api)"
	send -- "[your-linear-api-key]"

	expect "*Which service would you like to import from?"
	send -- "GitHub\r"

	expect "*Input your personal GitHub access token (https://github.com/settings/tokens, select `repo` scope)"
	send -- "[your-github-token]"

	expect "*From which repo do you want to import issues from (e.g. \"facebook/react\")"
	send -- "$repo\r"

	expect "*Do you want to create a new team for imported issues?"
	send -- "n\r"

	expect "*Import into team:"
	# down arrow 5x then enter is what I needed, you'll almost definitely need to adjust this
	send -- "\033\[B"
	send -- "\033\[B"
	send -- "\033\[B"
	send -- "\033\[B"
	send -- "\033\[B"
	send -- "\r"

	expect "*Do you want to import to a specific project?"
	send -- "n\r"

	# you might have to comment this out
	# I couldn't figure out how to handle optional prompts
	expect "*Do you want to include comments in the issue description?"
	send -- "y\r"

	expect "*Do you want to assign these issues to yourself?"
	send -- "n\r"

	expect "*Assign to user:"
	# as above, adjust the number of down arrows you need to use
	send -- "\033\[B"
	send -- "\r"

	expect eof
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants